00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00020 #ifndef MOREERRORMGR_H
00021 #define MOREERRORMGR_H
00022
00023 #ifdef __cplusplus
00024 extern "C" {
00025 #endif
00026
00027 #include "MorePrefix.h"
00028 #include "MoreTypes.h"
00029
00030 #include <ErrorBase.h>
00031
00095 #if MOREPALMOS_VERBOSE_FAILURE_MSGS
00096 #define merr_checkf( b )\
00097 ErrFatalDisplayIf( !( b ), "merr_checkf(" #b ") failed.")
00098 #else
00099 #define merr_checkf( b )\
00100 ErrFatalDisplayIf( !( b ), "Assertion failed.")
00101 #endif
00102
00107 #if MOREPALMOS_VERBOSE_FAILURE_MSGS
00108 #define merr_ncheckf( b )\
00109 ErrFatalDisplayIf( b, "merr_neheckf(" #b ") failed.")
00110 #else
00111 #define merr_ncheckf( b )\
00112 ErrFatalDisplayIf( b, "Assertion failed.")
00113 #endif
00114
00119 #if MOREPALMOS_VERBOSE_FAILURE_MSGS
00120 #define merr_checkp( b )\
00121 ErrNonFatalDisplay( !( b ), "merr_checkp(" #b ") failed.")
00122 #else
00123 #define merr_checkp( b )\
00124 ErrNonFatalDisplayIf( !( b ), "Assertion failed.")
00125 #endif
00126
00131 #if MOREPALMOS_VERBOSE_FAILURE_MSGS
00132 #define merr_ncheckp( b )\
00133 ErrNonFatalDisplay( !( b ), "merr_ncheckp(" #b ") failed.")
00134 #else
00135 #define merr_ncheckp( b )\
00136 ErrNonFatalDisplayIf( b, "Assertion failed.")
00137 #endif
00138
00139 #if ERROR_CHECK_LEVEL == ERROR_CHECK_FULL
00140 FormType* merr_validate_form_ptr( FormType* formP );
00141 #else
00142 #define merr_validate_form_ptr( formP ) formP
00143 #endif
00144
00145 #if ERROR_CHECK_LEVEL == ERROR_CHECK_FULL
00146 const FormType* merr_validate_const_form_ptr( const FormType* formP );
00147 #else
00148 #define merr_validate_const_form_ptr( formP ) formP
00149 #endif
00150
00151 #if ERROR_CHECK_LEVEL == ERROR_CHECK_FULL
00152 FrmObjectID_t merr_validate_object_id( const FormType* formP, FrmObjectID_t objID );
00153 #else
00154 #define merr_validate_object_id( formP, objID ) objID
00155 #endif
00156
00157 #if ERROR_CHECK_LEVEL == ERROR_CHECK_FULL
00158 FrmObjectIdx_t merr_validate_object_idx( const FormType* formP, FrmObjectIdx_t objIdx );
00159 #else
00160 #define merr_validate_object_idx( formP, objIdx ) objIdx
00161 #endif
00162
00163 #if ERROR_CHECK_LEVEL == ERROR_CHECK_FULL
00164 void* merr_validate_object_ptr( void* objP );
00165 #else
00166 #define merr_validate_object_ptr( objP ) objP
00167 #endif
00168
00169 #if ERROR_CHECK_LEVEL == ERROR_CHECK_FULL
00170 const void* merr_validate_const_object_ptr( const void* objP );
00171 #else
00172 #define merr_validate_const_object_ptr( objP ) objP
00173 #endif
00174
00175 #if ERROR_CHECK_LEVEL == ERROR_CHECK_FULL
00176 FieldType* merr_validate_field_ptr( FieldType* fieldP );
00177 #else
00178 #define merr_validate_field_ptr( fieldP ) fieldP
00179 #endif
00180
00181 #if ERROR_CHECK_LEVEL == ERROR_CHECK_FULL
00182 const FieldType* merr_validate_const_field_ptr( const FieldType* fieldP );
00183 #else
00184 #define merr_validate_const_field_ptr( fieldP ) fieldP
00185 #endif
00186
00187 #if ERROR_CHECK_LEVEL == ERROR_CHECK_FULL
00188 MemHandle merr_validate_memhandle( MemHandle memH );
00189 #else
00190 #define merr_validate_memhandle( memH ) memH
00191 #endif
00192
00193 #if ERROR_CHECK_LEVEL == ERROR_CHECK_FULL
00194 const MemHandle merr_validate_const_memhandle( const MemHandle memH );
00195 #else
00196 #define merr_validate_const_memhandle( memH ) memH
00197 #endif
00198
00205
00206 #if MOREPALMOS_INCLUDE_DEFAULT_FLOW_NOTIFICATIONS
00207 void __NotifyOfErrorVerbose( const char* file, Int16 line );
00208 void __NotifyOfError( );
00209 #endif
00210
00219 #define merr_require( success, label, notify )\
00220 { if ( !( success ) ) { _NotifyOfError( notify ); goto label; } }
00221
00222 #define merr_reject( failure, label, notify )\
00223 { if ( failure ) { _NotifyOfError( notify ); goto label; } }
00224
00225 #define merr_require_action( success, label, action, notify )\
00226 { if ( !( success ) ) { _NotifyOfError( notify ); { action; } goto label; } }
00227
00228 #define merr_reject_action( failure, label, action, notify )\
00229 { if ( failure ) { _NotifyOfError( notify ); { action; } goto label; } }
00230
00236
00237
00238
00239
00240
00241 #if MOREPALMOS_ERROR_MACROS
00242
00243 #define check( b )\
00244 merr_checkp( b )
00245 #define ncheck( b )\
00246 merr_ncheckp( b )
00247 #define checkf( b )\
00248 merr_checkf( b )
00249 #define ncheckf( b )\
00250 merr_ncheckf( b )
00251 #define checkp( b )\
00252 merr_checkp( b )
00253 #define ncheckp( b )\
00254 merr_ncheckp( b )
00255
00256 #define validate_form_ptr( formP )\
00257 merr_validate_form_ptr( formP )
00258 #define validate_const_form_ptr( formP )\
00259 merr_validate_const_form_ptr( formP )
00260 #define validate_object_id( formP, objID )\
00261 merr_validate_object_id( formP, objID )
00262 #define validate_object_idx( formP, objIdx )\
00263 merr_validate_object_idx( formP, objIdx )
00264 #define validate_object_ptr( objP )\
00265 merr_validate_object_ptr( objP )
00266 #define validate_const_object_ptr( objP )\
00267 merr_validate_const_object_ptr( objP )
00268 #define validate_field_ptr( fieldP )\
00269 merr_validate_field_ptr( fieldP )
00270 #define validate_const_field_ptr( fieldP )\
00271 merr_validate_const_field_ptr( fieldP )
00272 #define validate_memhandle( hand )\
00273 merr_validate_memhandle( hand )
00274 #define validate_const_memhandle( hand )\
00275 merr_validate_const_memhandle( hand )
00276
00277 #define require( success, label )\
00278 merr_require( condition, label, DEBUG )
00279 #define reject( success, label )\
00280 merr_reject( condition, label, DEBUG )
00281 #define require_action( success, label, action )\
00282 merr_reject_action( condition, label, action, DEBUG )
00283 #define reject_action( success, action )\
00284 merr_reject_action( condition, label, action, DEBUG )
00285
00286 #define require_( success, label, notify )\
00287 merr_require( condition, label, notify )
00288 #define reject_( success, label, notify )\
00289 merr_reject( condition, label, notify )
00290 #define require_action_( success, label, action, notify )\
00291 merr_reject_action( condition, label, action, notify )
00292 #define reject_action_( success, label, action, notify )\
00293 merr_reject_action( condition, label, action, notify )
00294
00295 #endif
00296
00297
00298 #if DEBUG_LEVEL==DEBUG_LEVEL_NONE
00299 #define _NotifyOfError( notify )\
00300 { }
00301 #elif MOREPALMOS_VERBOSE_FAILURE_MSGS
00302 #define _NotifyOfError( notify )\
00303 { if ( notify ) __NotifyOfErrorVerbose(__FILE__, _LINE ); }
00304 #else
00305 #define _NotifyOfError( notify )\
00306 { if ( notify ) __NotifyOfError( ); }
00307 #endif
00308
00309 #ifdef __cplusplus
00310 }
00311 #endif
00312
00313 #endif