gatelib  2.1
g_exception_macros.h
Go to the documentation of this file.
1 
2 #pragma once
3 
11 #define G_EXC_DEFINE_TAG(aexctypename,abaseexctypename,atag) \
13 class aexctypename : public abaseexctypename {\
14  public:\
15  aexctypename ( const std::wstring& msg , const Context& context ):abaseexctypename(msg,context){}\
16  aexctypename ( const std::string& msg , const Context& context ):abaseexctypename(msg,context){}\
17  aexctypename ( const Exception& inner , const Context& context ):abaseexctypename(inner,context){}\
18  virtual ~aexctypename (){}\
19  static const char* get_Tag ( ) { return atag; }\
20  virtual const char* getTag ( ) const { return get_Tag(); }\
21 }
22 
24 #define G_EXC_DEFINE_TAG_MSG(aexctypename,abaseexctypename,atag,amsg) \
25 class aexctypename : public abaseexctypename {\
26  public:\
27  aexctypename ( const std::wstring& msg , const Context& context ):abaseexctypename(msg,context){}\
28  aexctypename ( const std::string& msg , const Context& context ):abaseexctypename(msg,context){}\
29  aexctypename ( const Context& context ):abaseexctypename(G_STR(amsg),context){}\
30  aexctypename ( const Exception& inner , const Context& context ):abaseexctypename(inner,context){}\
31  virtual ~aexctypename (){}\
32  static const char* get_Tag ( ) { return atag; }\
33  virtual const char* getTag ( ) const { return get_Tag(); }\
34 }
35 
39 #define G_EXC_DEFINE(aexctypename,abaseexctypename) G_EXC_DEFINE_TAG ( aexctypename , abaseexctypename , G_STR (aexctypename) )
40 
43 #define G_EXC_DEFINE_MSG(aexctypename,abaseexctypename,amsg) G_EXC_DEFINE_TAG_MSG ( aexctypename , abaseexctypename , G_STR (aexctypename) , amsg )
44 
46 #define G_ASSERT(acondition) if(!(acondition)){ g::AssertException::do_FatalAction<g::Exception> ( "ASSERTION FAILED:\r\n" G_STR(acondition) , G_EXC_SIGNATURE() ); }
47 
52 #define G_EXC_SET_CONTEXT(acontextstr) static const char* _g_method_context = acontextstr;
53 
55 #define G_EXC_SIGNATURE() _g_method_context , __FILE__ , __LINE__
56 
58 #define G_EXC_RAISE_MSG(aexctype,amessage) g::Exception::do_RaiseMsg<aexctype> ( amessage , G_EXC_SIGNATURE() )
59 
61 #define G_EXC_RAISE(aexctype) g::Exception::do_Raise<aexctype> ( G_EXC_SIGNATURE() )
62 
64 #define G_EXC_FATAL_ACTION(amessage) g::Exception::do_FatalAction<g::Exception> ( amessage , G_EXC_SIGNATURE() );
65 
66 #if G_AUTOPTION_ON_WINDOWS
67 # define G_EXC_RAISE_WIN() g::WinException::do_Raise ( _g_sys_call , G_EXC_SIGNATURE() )
69 #endif
70 
81 #define G_SYS_CALL_ONLY(acall) GInt64_t _g_sys_result = (GInt64_t)( acall );static const char* _g_sys_call = G_STR(acall)
82 
86 #define G_WIN_CALL_ASSERT(awincall,acondition) G_SYS_CALL_ONLY(awincall); if( !(acondition) ){ G_EXC_RAISE_WIN(); }
87 
91 #define G_WIN_CALL(awincall) G_WIN_CALL_ASSERT( awincall , (_g_sys_result) )
92 
94 #define G_EXC_RAISE_POSIX() g::PosixException::do_Raise ( _g_sys_result , _g_sys_call , G_EXC_SIGNATURE() )
95 
99 #define G_POSIX_CALL_ASSERT(aposixcall,acondition) G_SYS_CALL_ONLY(aposixcall);if ( !(acondition) ) { G_EXC_RAISE_POSIX(); }
100 
104 #define G_POSIX_CALL(aposixcall) G_POSIX_CALL_ASSERT(aposixcall,(_g_sys_result==0))
105 
109 #define G_POSIX_CALL_VALUE(aposixcall) G_POSIX_CALL_ASSERT(aposixcall,(_g_sys_result!=-1))
110 
112 #define G_EXC_FRAME_BEGIN() try{
113 
127 #define G_EXC_FRAME_END_THREAD(athreadname) \
128  } catch ( g::Exception& exc ) { g::Exception::do_UnhandledExceptionHandling ( exc , athreadname ); }\
129  catch ( std::exception& exc ) { g::Exception::do_UnhandledExceptionHandling ( exc , athreadname ); }\
130  catch ( ... ) { g::Exception::generic_ExceptionCancelHandling();g::Exception::do_UnhandledExceptionHandling ( athreadname ); }
131 
133 #define G_EXC_FRAME_END_MAIN() G_EXC_FRAME_END_THREAD ( "MainThread" )
134 
136 //\param acontextstr specify, the call context like in G_EXC_SET_CONTEXT .
137 #define G_EXC_UNIMPLEMENTED(acontextstr) G_EXC_SET_CONTEXT(acontextstr); G_EXC_RAISE ( g::UnimplemetedException )
138 
140 #define G_EXC_FRAME_FILTER_RETHROW(afilterexc) } catch ( afilterexc& exc ) { g::Exception::do_Rethrow<afilterexc> ( exc , G_EXC_SIGNATURE() ); }
141