12.2 Base exceptional–condition objects

All the exceptional–condition objects must be subclasses of mbfl_exceptional_condition. We can subclass it as follows:

mbfl_default_class_declare(my_something_happened_t)

mbfl_default_class_define _(my_something_happened_t) \
    _(mbfl_exceptional_condition_t) 'my_something_happened'

function my_something_happened_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'

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

and we can use the subclass as follows:

mbfl_default_object_declare(CND)

my_something_happened_make _(CND) 'someone' 'something happened'
mbfl_exception_raise _(CND)

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