[Return to Bookshelf] [Contents] [Previous Section] [Next Section] [Index] [Help]


5.2.6 Reraising the Current Exception

Within the code block of a CATCH or CATCH_ALL macro, you can use RERAISE to allow outer exception scopes the chance to handle the exception. Do this when the current scope needs to restore some permanent state (for example, releasing resources such as memory or a mutex), but does not have enough context about the error to attempt to recover.

The RERAISE function is only valid in the code of a CATCH or CATCH_ ALL clause. For example:

int *local_mem;
local_mem = malloc (sizeof (int));

TRY {
   operation(local_mem);      /* May raise an exception */
   free (local_mem);
}
CATCH (an_error) {
   free (local_mem);
   RERAISE;
}