12.12 Invalid parameter to function call exceptional–condition objects

Invalid parameter to function call exceptional–conditions are used to signal a programming error. Example:

function myfunc () {
    mbfl_mandatory_parameter(MOOD, 1, the mood)

    if ! some_predicate "$MOOD"
    then
        mbfl_default_object_declare(CND)

        mbfl_invalid_function_parameter_condition_make _(CND) \
            $FUNCNAME 'expected good value' 1 'MOOD' "$MOOD"
        mbfl_exception_raise _(CND)
        return_because_failure
    fi

    # do something
}

Usually when an exceptional–condition of this class is raised, the correct handling is to: attempt a clean release of all the resources; inform the user; terminate the program with an appropriate exit status.


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