12.4 Error exceptional–condition objects

Error exceptional–conditions are used to signal an error in a procedure the script is executing. The abstract class mbfl_error_condition is meant to be the base of all the error exceptional–condition objects; we can subclass it as follows:

mbfl_default_class_declare(fatal_error_t)

mbfl_default_class_define _(fatal_error_t) _(mbfl_error_condition_t) 'fatal_error'

function fatal_error_make () {
    mbfl_mandatory_nameref_parameter(CND, 1, exceptional-condition object)
    mbfl_mandatory_parameter(WHO,         2, entity reporting the exceptional-condition)
    mbfl_mandatory_parameter(MESSAGE,     3, exceptional-condition description message)
    declare CONTINUABLE='true'

    fatal_error_define _(CND) "$WHO" "$MESSAGE" $CONTINUABLE
}

and we can use the subclass as follows:

mbfl_default_object_declare(CND)

fatal_error_make _(CND) 'someone' 'save yourself'
mbfl_exception_raise _(CND)

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