src/Common/Exception/Macros.h

Go to the documentation of this file.
00001 #pragma once
00002 
00003 #define CHECK_WIN32_DWORD( func, message ) \
00004 { \
00005         DWORD asi_macro_dw_err_ = ( func ); \
00006         if ( asi_macro_dw_err_ != 0 ) \
00007         { \
00008                 std::wstringstream ss_message; ss_message << message; \
00009         throw std::exception(AppSecInc::Exception::Win32Exception::GetErrorString(asi_macro_dw_err_, \
00010             ss_message.str().c_str()).c_str()); \
00011         } \
00012 }
00013 
00014 #define CHECK_WIN32_BOOL( func, message ) \
00015 { \
00016         if ( FALSE == ( func ) ) \
00017         { \
00018                 std::wstringstream ss_message; ss_message << message; \
00019         throw std::exception(AppSecInc::Exception::Win32Exception::GetLastErrorString( \
00020             ss_message.str().c_str()).c_str()); \
00021         } \
00022 }
00023 
00024 #define CHECK_BOOL( func, message ) \
00025 { \
00026         if ( FALSE == ( func ) ) \
00027         { \
00028                 std::wstringstream ss_message; ss_message << message; \
00029                 throw std::exception(AppSecInc::StringUtils::wc2mb(ss_message.str()).c_str()); \
00030         } \
00031 }
00032 
00033 #define THROW( message ) \
00034 { \
00035         std::wstringstream ss_message; ss_message << message; \
00036         throw std::exception(AppSecInc::StringUtils::wc2mb(ss_message.str()).c_str()); \
00037 }
00038 
00039 #define CHECK_HR( func, message ) \
00040 { \
00041         HRESULT asi_macro_hr_ = ( func ); \
00042         if (FAILED(asi_macro_hr_)) \
00043         { \
00044                 std::wstringstream ss_message; ss_message << message; \
00045         throw std::exception(AppSecInc::Exception::Win32Exception::GetErrorString(asi_macro_hr_, \
00046             ss_message.str().c_str()).c_str()); \
00047         } \
00048 }


© Application Security Inc. - All Rights Reserved http://msiext.codeplex.com