diff options
author | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:23:48 +0200 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:23:48 +0200 |
commit | ee1c8c5c25d25dfa42120125a8a45dc9831ee412 (patch) | |
tree | 67aa287157db954e0cadeee05b4aad331eb2ecf2 /zen/com_error.h | |
parent | 5.13 (diff) | |
download | FreeFileSync-ee1c8c5c25d25dfa42120125a8a45dc9831ee412.tar.gz FreeFileSync-ee1c8c5c25d25dfa42120125a8a45dc9831ee412.tar.bz2 FreeFileSync-ee1c8c5c25d25dfa42120125a8a45dc9831ee412.zip |
5.14
Diffstat (limited to 'zen/com_error.h')
-rw-r--r-- | zen/com_error.h | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/zen/com_error.h b/zen/com_error.h index e6f5b492..0e0448a7 100644 --- a/zen/com_error.h +++ b/zen/com_error.h @@ -26,10 +26,11 @@ private: std::wstring msg_; }; -#define ZEN_CHECK_COM(func) ZEN_CHECK_COM_ERROR(func, #func) //throw ComError -/*Convenience Macro checking for COM errors: +//Convenience Macros checking for COM errors: -Example: ZEN_CHECK_COM(backupComp->InitializeForBackup()); +#define ZEN_COM_CHECK(func) ZEN_COM_CHECK_IMPL(func, #func) //throw ComError +/* +Example: ZEN_COM_CHECK(backupComp->InitializeForBackup()); Equivalent to: { @@ -39,6 +40,15 @@ Equivalent to: } */ +#define ZEN_COM_ASSERT(obj) ZEN_COM_ASSERT_IMPL(obj, #obj) //throw ComError +/* +Example: ZEN_COM_ASSERT(obj); + +Equivalent to: + if (!obj) + throw ComError(L"Assertion failed: \"obj\".", E_FAIL); +*/ + @@ -218,16 +228,13 @@ std::wstring generateErrorMsg(const std::wstring& input, HRESULT hr) } -#define ZEN_CHECK_COM_ERROR(func, txt) \ - { \ - HRESULT hrInternal = func; \ - if (FAILED(hrInternal)) \ - throw ComError(L"Error calling \"" ## ZEN_CONCAT_SUB(L, txt) ## L"\".", hrInternal); \ +#define ZEN_COM_CHECK_IMPL(func, txt) \ + { \ + HRESULT hrInternal = func; \ + if (FAILED(hrInternal)) \ + throw zen::ComError(std::wstring(L"Error calling \"") + L ## txt + L"\".", hrInternal); \ } -#ifndef ZEN_CONCAT //redeclare those macros: avoid dependency to scope_guard.h -#define ZEN_CONCAT_SUB(X, Y) X ## Y -#define ZEN_CONCAT(X, Y) ZEN_CONCAT_SUB(X, Y) -#endif +#define ZEN_COM_ASSERT_IMPL(obj, txt) if (!(obj)) throw zen::ComError(std::wstring(L"Assertion failed: \"") + L ## txt + L"\".", E_FAIL); } #endif //COM_ERROR_HEADER |