40#ifndef ERIS_IFU_ERROR_H
41#define ERIS_IFU_ERROR_H
53#if defined HAVE_DECL___FUNC__ && !HAVE_DECL___FUNC__
157 int eris_ifu_error_is_set_where = 0, \
158 eris_ifu_error_catch_call_flag; \
159 cpl_errorstate eris_ifu_error_state; \
161 eris_ifu_error_state = cpl_errorstate_get(); \
176 goto _ERIS_IFU_CATCH_LABEL_; \
177 _ERIS_IFU_CATCH_LABEL_: \
179 if ((eris_ifu_error_catch_call_flag = \
180 !cpl_errorstate_is_equal(eris_ifu_error_state))) \
182 if (!eris_ifu_error_is_set_where) \
183 cpl_error_set_where(__func__); \
185 if (eris_ifu_error_catch_call_flag)
198#define GET_NEW_ERROR(void) \
199 (cpl_errorstate_is_equal(eris_ifu_error_state) ? \
201 cpl_error_get_code() \
213#define RECOVER(void) \
214 cpl_errorstate_set(eris_ifu_error_state)
225#define SET_ERROR(code) \
227 if (code != CPL_ERROR_NONE) \
229 cpl_error_set(__func__, code); \
230 eris_ifu_error_is_set_where = __LINE__; \
246#define SET_ERROR_MSG(code, msg) \
248 if (code != CPL_ERROR_NONE) \
250 cpl_error_set_message(__func__, code, msg); \
251 eris_ifu_error_is_set_where = __LINE__; \
266#define CHECK_ERROR_STATE(void) \
268 if (!cpl_errorstate_is_equal(eris_ifu_error_state)) \
270 cpl_error_set_where(__func__); \
271 eris_ifu_error_is_set_where = __LINE__; \
272 ERIS_IFU_TRY_EXIT(); \
286#define CHECK_ERROR_STATE_MSG(msg) \
288 if (!cpl_errorstate_is_equal(eris_ifu_error_state)) \
290 cpl_error_set_where(__func__); \
291 cpl_msg_error(__func__, "%s", msg); \
292 eris_ifu_error_is_set_where = __LINE__; \
293 ERIS_IFU_TRY_EXIT(); \
306#define BRK_WITH_ERROR(code) \
308 cpl_error_set(__func__, code); \
309 eris_ifu_error_is_set_where = __LINE__; \
310 ERIS_IFU_TRY_EXIT(); \
322#define BRK_WITH_ERROR_MSG(code, ...) \
324 cpl_error_set_message(__func__, code, __VA_ARGS__); \
325 eris_ifu_error_is_set_where = __LINE__; \
326 ERIS_IFU_TRY_EXIT(); \
339#define BRK_IF_ERROR(function) \
341 if ((function) != CPL_ERROR_NONE) \
343 cpl_error_set_where(__func__); \
344 eris_ifu_error_is_set_where = __LINE__ ; \
345 ERIS_IFU_TRY_EXIT(); \
360#define BRK_IF_NULL(function) \
362 if ((function) == NULL) \
364 cpl_error_set_where(__func__); \
365 eris_ifu_error_is_set_where = __LINE__ ; \
366 ERIS_IFU_TRY_EXIT(); \
380#define ERIS_IFU_TRY_EXIT_IF_NOT(condition) \
384 cpl_error_set_where(__func__); \
385 eris_ifu_error_is_set_where = __LINE__; \
386 ERIS_IFU_TRY_EXIT(); \
400#define ERIS_IFU_TRY_EXIT(void) \
401 goto _ERIS_IFU_CATCH_LABEL_
409#define ASSURE(condition, error, ...) \
410do if (!(condition)) { \
411 cpl_error_set_message(cpl_func, \
414 eris_ifu_error_is_set_where = __LINE__; \
415 ERIS_IFU_TRY_EXIT(); \
429 cpl_msg_error(cpl_func, \
430 "%s (Code %d) in %s", \
431 cpl_error_get_message(), \
432 cpl_error_get_code(), \
433 cpl_error_get_where()); \
445#define CATCH_MSGS() \
447 cpl_errorstate_dump(0, CPL_FALSE, NULL); \