ECL_HANDLER_CASE — C macro for handler-case


} ECL_HANDLER_CASE(n,condition) { {


ECL_HANDLER_CASE_BEGIN runs a block of C code with a set of error handlers bound to the names given by the list names. The subsequent ECL_HANDLER_CASE statements specify what to do when the n-th type of conditions is found, where n is an integer denoting the position of the name in the list names.

When a condition is signaled, ECL scans the list of signal handlers, looking for matches based on typep. If the match with the highest precedence belongs to the list names, ECL will perform a non-local transfer of control to the appropriate ECL_HANDLER_CASE, passing it a condition object as unique argument.

The following example shows how to establish a handler for ERROR conditions. Note how the first value to ECL_HANDLER_CASE matches the position of the restart name in the list:

cl_object error = ecl_make_symbol("ERROR","CL");
ECL_HANDLER_CASE_BEGIN(the_env, ecl_list1(error)) {
   /* This form is evaluated with bound handlers */
   output = cl_eval(1, form);
} ECL_HANDLER_CASE(1, condition) {
   /* This code is executed when an error happens */
   /* We just return the error that took place */
   output = condition;