-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.h
32 lines (26 loc) · 1.3 KB
/
utils.h
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
27
28
29
30
31
32
//
// Created by disc on 1/16/2021.
//
#ifndef CAM_CLI_UTILS_H
#define CAM_CLI_UTILS_H
#include <iostream>
#include <system_error>
#define THROW_IF_FAILED(hr) \
{ \
if (FAILED(hr)) { \
auto error = get_hr_error_message(hr); \
throw std::runtime_error(error); \
} \
}
#define RETURN_IF_FAILED(hr) \
{ \
if (FAILED(hr)) { \
auto error = get_hr_error_message(hr); \
std::cout << "HRESULT error: " << error << std::endl; \
return {}; \
} \
}
inline std::string get_hr_error_message(HRESULT hr) {
return std::system_category().message(hr);
}
#endif//CAM_CLI_UTILS_H