diff options
| author | Konstantin <const@const.me> | 2023-01-16 14:52:43 +0100 |
|---|---|---|
| committer | Konstantin <const@const.me> | 2023-01-16 14:52:43 +0100 |
| commit | 8c4603c73675958efc960fbd4bb599a2909d106a (patch) | |
| tree | 714dc6fc9a1672d5fd7f89676b97e10959662abc /ComLightLib/Exception.hpp | |
| parent | 990a8d0dbaefc996244097397259e92758b15cce (diff) | |
Source codes
Diffstat (limited to 'ComLightLib/Exception.hpp')
| -rw-r--r-- | ComLightLib/Exception.hpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/ComLightLib/Exception.hpp b/ComLightLib/Exception.hpp new file mode 100644 index 0000000..57c1b78 --- /dev/null +++ b/ComLightLib/Exception.hpp @@ -0,0 +1,20 @@ +#pragma once + +namespace ComLight +{ + class Exception : public std::runtime_error + { + // I don't like C++ exceptions too much, but for some cases they are useful. + // You can throw ComLight::Exception from constructor, or from FinalConstruct() method, the library will catch & return the code from the class factory function. + // Unfortunately, for interface methods this doesn't work, the C++ parts of the library can't catch them without very complex trickery like code generation. + // You can still use this class in methods, but you'll need to catch them manually near the API boundary or the app will crash. + // C++ doesn't have an ABI, the framework can't catch C++ exception across the modules. + const HRESULT m_code; + + public: + + Exception( HRESULT hr ) : runtime_error( "ComLight HRESULT exception" ), m_code( hr ) { } + + HRESULT code() const { return m_code; } + }; +}
\ No newline at end of file |
