acme
Foundational cross-platform layer of the ca2 framework
Loading...
Searching...
No Matches
hresult_exception.h
1#pragma once
2
3
4#include "acme/exception/exception.h"
5#include "acme/_operating_system.h"
6
7
8class CLASS_DECL_ACME hresult_exception :
9 public ::exception
10{
11public:
12
13
14 hresult_exception(HRESULT hresult, const_char_pointer pszMessage = nullptr);
15 ~hresult_exception() override;
16
17
18};
19
20
21inline ::string hresult_text(HRESULT hresult)
22{
23
24 return ::windows::last_error_message((DWORD)hresult);
25
26}
27
28
29inline void defer_throw_hresult(HRESULT hresult)
30{
31
32 if (FAILED(hresult))
33 {
34
35 throw hresult_exception(hresult);
36
37 }
38
39}
40
41
42inline error_code hresult_error_code(HRESULT hresult)
43{
44
45 return { e_error_code_type_hresult, (::i64)hresult };
46
47}
48
49
50
51CLASS_DECL_ACME ::string hresult_to_string(HRESULT hr);
52
Definition error_code.h:22
Definition hresult_exception.h:10