GNU-Bash-Shell-Script-Template
GNU-Bash-Shell-Script-Template copied to clipboard
Code bloat: Why should meta_trap_err() display error about itself?
I can't grab the idea behind this design:
meta_trap_err(){
if [ ${#} -ne 4 ]; then
printf 'ERROR: %s: Wrong function argument quantity!\n' "${FUNCNAME[0]}" 1>&2
return "${COMMON_RESULT_FAILURE}"
fi
local -ir line_error_location=${1}; shift # The line number that triggers the error
local -r failing_command="${1}"; shift # The failing command
local -ir failing_command_return_status=${1}; shift # The failing command's return value
local -r failing_function="${1}"
meta_trap_err_print_debugging_info "${line_error_location}" "${failing_command}" "${failing_command_return_status}" "${failing_function}"
return "${COMMON_RESULT_SUCCESS}"
}; declare -fr meta_trap_err
And this:
meta_trap_err_print_debugging_info(){
if [ ${#} -ne 4 ]; then
printf 'ERROR: %s: Wrong function argument quantity!\n' "${FUNCNAME[0]}" 1>&2
return "${COMMON_RESULT_FAILURE}"
fi
...
Functions intending to display errors need to display error about themselves?
(Funny error message picture: Dialog box saying "An error occurred while displaying previous error.")
Enough said.