13.3 How to raise exceptional–condition objects

Function: mbfl_exception_raise CND

Raise an exceptional condition represented by CND, which must be an object whose class is a subclass of mbfl_exceptional_condition, Base exceptional–condition objects.

Starting from the top of exception–handlers’s stack: apply the next handler to CND. The handler should try to react to the exception.

  • The handler might exit the script.
  • If the handler returns using return_success_after_handling_exception: it matters if the exceptional–condition object is continuable, continuable of mbfl_exceptional_condition.
    • If CND is continuable: mbfl_exception_raise() will return to the caller with return status ‘0’; this should resume script’s execution.
    • If CND is non–continuable: mbfl_exception_raise() will call exit_because_non_continuable_exception(); this will exit the script after running the atexit scripts, if we have enabled them; Running scripts at exit–time.
  • If the handler returns using return_failure_after_handling_exception: mbfl_exception_raise() returns to its caller with return_failure; this is meant to cause the calling functions to return with failure status up until the “beginning of task” position in the script.
  • If the handler returns using return_after_not_handling_exception: mbfl_exception_raise() will apply to CND the next handler from the stack. If no client exception–handler returns successfully: the default exception–handler will call exit_because_uncaught_exception().
Preprocessor Macro: mbfl_exception_raise_then_return_failure (CND)

Expand as follows:

mbfl_exception_raise_then_return_failure(CND)
→ { mbfl_exception_raise CND ; return_because_failure ; }

This document describes version 3.0.0-devel.9 of Marcos Bash Functions Library.