7 :
public std::exception {
20 strcpy_s(
function, 255, _function);
25 return "HRESULT exception";
30 template<
bool ThrowException>
33 static bool Check(HRESULT _hr);
39 static bool Check(
const HRESULT& _hr) {
48 static bool Check(
const HRESULT& _hr) {
50 throw std::exception(
"HResult exception");
58 template<
bool ThrowException>
69 std::basic_string<WCHAR>
desc;
74 WORD code = HRESULT_CODE(_hr);
75 WORD facility = HRESULT_FACILITY(_hr);
76 DWORD severity = HRESULT_SEVERITY(_hr);
83 HResultT(
const HRESULT& _hr = S_OK,
const char _function[] =
"none")
85 strcpy_s(
function, 255, _function);
91 HResultT& operator() (
const char _function[] =
"none") {
92 strcpy_s(
function, 255, _function);
96 HResultT& operator() (
const HRESULT& _hr,
const char _function[] =
"none") {
97 strcpy_s(
function, 255, _function);
102 HResultT& operator= (
const HRESULT& _hr) {
114 operator HRESULT ()
const {
Exception class for HRESULTs.
static bool Check(HRESULT _hr)
Check.
std::basic_string< WCHAR > desc
more description
void Assign(const HRESULT &_hr)
Assign a HRESULT.
static bool Check(const HRESULT &_hr)
HRESULT hr
Current HRESULT.
LPCTSTR ErrrorMessage() const
Class around a HRESULT which breaks down the HRESULT code and makes life easier etc.
const char * what() const
HResultT(const HRESULT &_hr=S_OK, const char _function[]="none")
Constructor.
Templated helper class to check an HRESULT and throw an exception (or not throw)
hresult_exception(const HRESULT &_hr=S_OK, const char _function[]="none")
static bool Check(const HRESULT &_hr)