sculpto
Main Page
Namespaces
Classes
Files
File List
File Members
utilities
macros
throw_if_failed.h
Go to the documentation of this file.
1
/*!****************************************************************/
/*!*
2
* \file throw_if_failed.h
3
* \brief Helper throw if failed inline function implementation function.
4
* Commonly used in DirectX module.
5
*
6
* \author Sabitov Kirill
7
* \date 22 June 2022
8
*********************************************************************/
9
10
#pragma once
11
12
#include "
sclpch.h
"
13
14
namespace
scl::dx
15
{
17
class
com_exeption
:
public
std::exception
18
{
19
private
:
21
HRESULT Result;
22
23
public
:
25
com_exeption
(HRESULT hr) :Result(hr) {}
26
27
const
char
*
what
()
const override
28
{
29
static
char
str[64] {};
30
sprintf_s(str,
"Failure with HRESULT of %08X"
,
31
static_cast<
unsigned
int
>
(Result));
32
return
str;
33
}
34
};
35
36
/*!*
37
* Helper utility converts D3D API failures into exceptions.
38
*
39
* \param hr COM result handle.
40
* \return None.
41
*/
42
inline
void
ThrowIfFailed
(HRESULT hr)
43
{
44
if
(FAILED(hr))
45
{
46
throw
com_exeption
(hr);
47
}
48
}
49
}
scl::dx::com_exeption
Definition:
throw_if_failed.h:18
scl::dx::com_exeption::com_exeption
com_exeption(HRESULT hr)
Definition:
throw_if_failed.h:25
scl::dx::com_exeption::what
const char * what() const override
Definition:
throw_if_failed.h:27
scl::dx
Definition:
throw_if_failed.h:15
scl::dx::ThrowIfFailed
void ThrowIfFailed(HRESULT hr)
Definition:
throw_if_failed.h:42
sclpch.h
Sculpto library prehompiled header. Defines common definitions, includes commonly used modules.
Generated by
1.9.4