forked from MicrosoftEdge/WebView2Samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCheckFailure.cpp
More file actions
26 lines (22 loc) · 741 Bytes
/
CheckFailure.cpp
File metadata and controls
26 lines (22 loc) · 741 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// Copyright (C) Microsoft Corporation. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "stdafx.h"
#include <iomanip>
#include <sstream>
// Notify the user of a failure with a message box.
void ShowFailure(HRESULT hr, const std::wstring& message)
{
std::wstringstream formattedMessage;
formattedMessage << message << ": 0x" << std::hex << std::setw(8) << hr;
MessageBox(nullptr, formattedMessage.str().c_str(), nullptr, MB_OK);
}
// If something failed, show the error code and fail fast.
void CheckFailure(HRESULT hr, const std::wstring& message)
{
if (FAILED(hr))
{
ShowFailure(hr, message);
FAIL_FAST();
}
}