ERIS Pipeline Reference Manual 1.8.15
#define TRY
 Beginning of a TRY-block.
 
#define CATCH
 End of a TRY-block, beginning of a CATCH-block.
 
#define GET_NEW_ERROR(void)
 Return new CPL error code.
 
#define RECOVER(void)
 Recover the error state which was present during TRY (at the beginning of the try-block).
 
#define SET_ERROR(code)
 Set a new error code.
 
#define SET_ERROR_MSG(code, msg)
 Set a new error code together with a custom error message.
 
#define CHECK_ERROR_STATE(void)
 Check the CPL error state, and exit the try-block if not CPL_ERROR_NONE.
 
#define CHECK_ERROR_STATE_MSG(msg)
 Check the CPL error state, and exit the try-block if not CPL_ERROR_NONE. An additional error message using cpl_msg_error is "printed".
 
#define BRK_WITH_ERROR(code)
 Set a new CPL error, and exit the try-block.
 
#define BRK_WITH_ERROR_MSG(code, ...)
 Set a new CPL error, and exit the try-block.
 
#define BRK_IF_ERROR(function)
 If function is or returns an error != CPL_ERROR_NONE, then the try-block is exited.
 
#define BRK_IF_NULL(function)
 If function is or returns a NULL pointer, then the try-block is exited.
 
#define ERIS_IFU_TRY_EXIT_IF_NOT(condition)
 If condition == 0, then the try-block is exited.
 
#define ERIS_IFU_TRY_EXIT(void)
 The try-block is exited.
 
#define ASSURE(condition, error, ...)
 error handling macro (from fors-pipeline)
 
#define CATCH_MSG()
 Displays an error message.
 
#define CATCH_MSGS()
 Displays an error message stack.
 

Detailed Description

Macro Definition Documentation

◆ ASSURE

#define ASSURE (   condition,
  error,
  ... 
)
Value:
do if (!(condition)) { \
cpl_error_set_message(cpl_func, \
error, \
__VA_ARGS__); \
eris_ifu_error_is_set_where = __LINE__; \
ERIS_IFU_TRY_EXIT(); \
} while(0)

error handling macro (from fors-pipeline)

Parameters
conditionboolean expression to evaluate
errorerror to set

Definition at line 409 of file eris_ifu_error.h.

◆ BRK_IF_ERROR

#define BRK_IF_ERROR (   function)

If function is or returns an error != CPL_ERROR_NONE, then the try-block is exited.

  • It is assumed, that a returned error is already set as the new error state.
  • Forbidden in catch-block!

Definition at line 339 of file eris_ifu_error.h.

◆ BRK_IF_NULL

#define BRK_IF_NULL (   function)

If function is or returns a NULL pointer, then the try-block is exited.

  • It is assumed, that a new error state is already set if function is NULL.
  • Forbidden in catch-block!

Definition at line 360 of file eris_ifu_error.h.

◆ BRK_WITH_ERROR

#define BRK_WITH_ERROR (   code)

Set a new CPL error, and exit the try-block.

  • code must not be CPL_ERROR_NONE!
  • Forbidden in catch-block!

Definition at line 306 of file eris_ifu_error.h.

◆ BRK_WITH_ERROR_MSG

#define BRK_WITH_ERROR_MSG (   code,
  ... 
)

Set a new CPL error, and exit the try-block.

  • code must not be CPL_ERROR_NONE!
  • Forbidden in catch-block!

Definition at line 322 of file eris_ifu_error.h.

◆ CATCH

#define CATCH

End of a TRY-block, beginning of a CATCH-block.

Please refer to TRY.

Definition at line 173 of file eris_ifu_error.h.

◆ CATCH_MSG

#define CATCH_MSG ( )

Displays an error message.

  • To be used in catch-block!

Definition at line 427 of file eris_ifu_error.h.

◆ CATCH_MSGS

#define CATCH_MSGS ( )

Displays an error message stack.

  • To be used in catch-block!

Definition at line 445 of file eris_ifu_error.h.

◆ CHECK_ERROR_STATE

#define CHECK_ERROR_STATE (   void)

Check the CPL error state, and exit the try-block if not CPL_ERROR_NONE.

  • Forbidden in catch-block!

Definition at line 266 of file eris_ifu_error.h.

◆ CHECK_ERROR_STATE_MSG

#define CHECK_ERROR_STATE_MSG (   msg)

Check the CPL error state, and exit the try-block if not CPL_ERROR_NONE. An additional error message using cpl_msg_error is "printed".

  • Forbidden in catch-block!

Definition at line 286 of file eris_ifu_error.h.

◆ ERIS_IFU_TRY_EXIT

#define ERIS_IFU_TRY_EXIT (   void)

The try-block is exited.

  • It is not necessary that a new error state is already set. In this case, the try-block is just exited.
  • Forbidden in catch-block!

Definition at line 400 of file eris_ifu_error.h.

◆ ERIS_IFU_TRY_EXIT_IF_NOT

#define ERIS_IFU_TRY_EXIT_IF_NOT (   condition)

If condition == 0, then the try-block is exited.

  • It is assumed, that a new error state is already set if condition is 0.
  • Forbidden in catch-block!

Definition at line 380 of file eris_ifu_error.h.

◆ GET_NEW_ERROR

#define GET_NEW_ERROR (   void)

Return new CPL error code.

Returns
If the CPL error state has changed since TRY, the latest error code is returned, otherwise CPL_ERROR_NONE.
  • May be called in catch-block.

Definition at line 198 of file eris_ifu_error.h.

◆ RECOVER

#define RECOVER (   void)

Recover the error state which was present during TRY (at the beginning of the try-block).

  • May be called in catch-block.

Definition at line 213 of file eris_ifu_error.h.

◆ SET_ERROR

#define SET_ERROR (   code)

Set a new error code.

  • If code is CPL_ERROR_NONE, then RECOVER() is called.
  • May be called in catch-block.

Definition at line 225 of file eris_ifu_error.h.

◆ SET_ERROR_MSG

#define SET_ERROR_MSG (   code,
  msg 
)

Set a new error code together with a custom error message.

  • If code is CPL_ERROR_NONE, then RECOVER() is called, without setting a message.
  • May be called outside TRY-block.

Definition at line 246 of file eris_ifu_error.h.

◆ TRY

#define TRY

Beginning of a TRY-block.

The macro TRY is to be used like a keyword in front of a deeper scope. This scope has to be followed by the macro CATCH. This means that TRY and CATCH build a frame around a code statement or a code scope, called the try-block.

The CATCH macro is to be followed by a statement or scope, which is only executed if a CPL error is set while reaching the CATCH macro, called the catch-block.

The try-block can be exited by using one of the macros below, for example with BRK_WITH_ERROR(). In this case, a jump to CATCH is performed, and the catch-block executed if an error is set.

Note

The following constraints have to be fulfilled:

  • A "return" or "goto" statement inside the try-block is forbidden, because leaving the try-block without processing the CATCH macro will mess up the error state information. In the catch-block (which comes after the CATCH macro), it is allowed.
  • The macros require some variables, which are declared at the beginning of the TRY macro. Therefore it is not possible in ANSI-C to have code statements (except declarations) before the TRY macro. If it is required, this can be solved by putting a scope around the try-catch construct.
  • Only one TRY - CATCH - construct can be inside one function.
Example 1:
cpl_error_code my_func()
{
cpl_object *obj = NULL;
cpl_error_code error = CPL_ERROR_NONE;
{
obj = cpl_object_new());
cpl_function(obj));
}
{
error = cpl_error_get_code();
}
cpl_object_delete(obj);
return error;
}
#define BRK_IF_ERROR(function)
If function is or returns an error != CPL_ERROR_NONE, then the try-block is exited.
#define TRY
Beginning of a TRY-block.
#define CATCH
End of a TRY-block, beginning of a CATCH-block.
#define BRK_IF_NULL(function)
If function is or returns a NULL pointer, then the try-block is exited.
Example 2:
cpl_object *my_func()
{
cpl_object *obj = NULL;
{
obj = cpl_object_new());
cpl_function(obj));
}
{
cpl_object_delete(obj);
obj = NULL;
}
return obj;
}

Definition at line 156 of file eris_ifu_error.h.