Wrong parameters number to function call exceptional–conditions are used to signal a programming error. Example:
function myfunc () { if ((3 > $#)) then mbfl_default_object_declare(CND) mbfl_wrong_parameters_number_condition_make _(CND) $FUNCNAME 3 $# mbfl_exception_raise_then_return_failure(_(CND)) fi mbfl_mandatory_parameter(ALPHA, 1, the alpha) mbfl_mandatory_parameter(BETA, 2, the beta) mbfl_mandatory_parameter(GAMMA, 3, the gamma) mbfl_optional_parameter(DELTA, 4) # do something }
which we can abbreviate with:
function myfunc () { mbfl_check_mandatory_parameters_number(3) mbfl_mandatory_parameter(ALPHA, 1, the alpha) mbfl_mandatory_parameter(BETA, 2, the beta) mbfl_mandatory_parameter(GAMMA, 3, the gamma) mbfl_optional_parameter(DELTA, 4) # 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.
• conditions wrong parm number class: | Class definition of mbfl_wrong_parameters_number_condition .
| |
• conditions wrong parm number constructors: | Class constructors of mbfl_wrong_parameters_number_condition .
| |
• conditions wrong parm number attributes: | Attributes of mbfl_wrong_parameters_number_condition .
|
This document describes version 3.0.0-devel.9 of Marcos Bash Functions Library.