35 #ifndef CLIPM_PRIV_ERROR_H
36 #define CLIPM_PRIV_ERROR_H
50 #define _CLIPM_ERROR_SET_WHERE_() \
52 if (CLIPM_ERROR_IS_SET()) \
57 _msg = cpl_error_get_message(); \
59 while (_msg[_n] != '\0' && _msg[_n] != ':') \
61 while (_msg[_n] == ':' || _msg[_n] == ' ') \
63 cpl_error_set_message( __func__, \
64 cpl_error_get_code(), \
66 clipm_error_is_set_where = 1; \
70 #define _CLIPM_ERROR_SET_MSG_(code, object, msg) \
72 char _clipm_error_msg[256]; \
73 _clipm_priv_error_sprint_messages( _clipm_error_msg, \
77 cpl_error_set_message( __func__, \
79 "%s", _clipm_error_msg); \
80 clipm_error_is_set_where = 1; \
173 int clipm_error_catch_call_flag, \
174 clipm_error_is_set_where = 0; \
175 cpl_errorstate clipm_error_trystate; \
177 clipm_error_trystate = cpl_errorstate_get(); \
189 #define CLIPM_CATCH \
192 goto _CLIPM_CATCH_LABEL_; \
193 _CLIPM_CATCH_LABEL_: \
195 if ((clipm_error_catch_call_flag = (CLIPM_ERROR_IS_SET()))) \
197 if (!clipm_error_is_set_where) \
198 _CLIPM_ERROR_SET_WHERE_(); \
201 if (clipm_error_catch_call_flag)
214 #define CLIPM_ERROR_GET_NEW_SINCE_TRY(void) \
215 (CLIPM_ERROR_IS_NONE() ? CPL_ERROR_NONE : cpl_error_get_code())
226 #define CLIPM_ERROR_RECOVER_TRYSTATE(void) \
228 cpl_errorstate_set(clipm_error_trystate); \
229 clipm_error_is_set_where = 0; \
241 #define CLIPM_ERROR_SET(code) \
243 CLIPM_TRY_ASSERT(code != CPL_ERROR_NONE); \
244 cpl_error_set(__func__, code); \
245 clipm_error_is_set_where = 1; \
257 #define CLIPM_ERROR_SET_MSG(code, object, msg) \
259 CLIPM_TRY_ASSERT(code != CPL_ERROR_NONE); \
260 _CLIPM_ERROR_SET_MSG_(code, object, msg); \
273 #define CLIPM_ERROR_SET_MSG_IF_CODE(code, object, msg) \
275 CLIPM_TRY_ASSERT(code != CPL_ERROR_NONE); \
276 if (CLIPM_ERROR_GET_NEW_SINCE_TRY() == code) \
277 _CLIPM_ERROR_SET_MSG_(code, object, msg); \
291 #define CLIPM_ERROR_IS_SET(void) \
292 (!cpl_errorstate_is_equal(clipm_error_trystate))
305 #define CLIPM_ERROR_IS_NONE(void) \
306 (cpl_errorstate_is_equal(clipm_error_trystate))
322 #define CLIPM_TRY_CHECK(condition, code, object, msg) \
326 CLIPM_ERROR_SET_MSG( (code), (object), (msg)); \
343 #define CLIPM_TRY_CHECK_AUTOMSG(condition, code) \
347 CLIPM_ERROR_SET_MSG( (code), "!("#condition")", ""); \
362 #define CLIPM_TRY_CHECK_ERROR_STATE(void) \
364 if (CLIPM_ERROR_IS_SET()) \
366 if (!clipm_error_is_set_where) \
367 _CLIPM_ERROR_SET_WHERE_(); \
382 #define CLIPM_TRY_ASSERT(condition) \
386 _CLIPM_ERROR_SET_MSG_( CLIPM_ERROR_UNEXPECTED, \
388 _CLIPM_MSG_ERR_UNEXPECTED); \
403 #define CLIPM_TRY_ASSERT_ERROR_STATE(void) \
405 if (CLIPM_ERROR_IS_SET()) \
407 _CLIPM_ERROR_SET_MSG_( CLIPM_ERROR_UNEXPECTED, \
409 _CLIPM_MSG_ERR_UNEXPECTED); \
423 #define CLIPM_TRY_EXIT_WITH_ERROR(code) \
425 CLIPM_ERROR_SET((code)); \
440 #define CLIPM_TRY_EXIT_WITH_ERROR_MSG(code, object, msg) \
442 CLIPM_ERROR_SET_MSG((code), (object), (msg)); \
461 #define CLIPM_TRY_EXIT_IFN(condition) \
465 CLIPM_TRY_ASSERT(CLIPM_ERROR_IS_SET()); \
466 if (!clipm_error_is_set_where) \
467 _CLIPM_ERROR_SET_WHERE_(); \
482 #define CLIPM_TRY_EXIT(void) \
483 goto _CLIPM_CATCH_LABEL_
const char _CLIPM_MSG_ERR_UNEXPECTED[]
Internal error.
Definition: clipm_priv_error.c:26
const char CLIPM_MSG_ERR_DIFFSIZES[]
Location matrices differ in size.
Definition: clipm_priv_error.c:34
enum _clipm_error_code_ clipm_error_code
Extension to CPL error codes.
void _clipm_priv_error_sprint_messages(char *outstr, const char *msg1, const char *msg2, size_t maxlen)
Definition: clipm_priv_error.c:58
Definition: clipm_priv_error.h:503
_clipm_error_code_
Extension to CPL error codes.
Definition: clipm_priv_error.h:502
const char CLIPM_MSG_ERR_2ROWXY[]
Location matrix must contain 2 rows.
Definition: clipm_priv_error.c:32
const char _CLIPM_MSG_ERR_HANDLING[]
Internal error handling bug.
Definition: clipm_priv_error.c:29
const char CLIPM_MSG_ERR_DIFFTYPES[]
Location matrices differ in size.
Definition: clipm_priv_error.c:36