|
|
|
@ -105,6 +105,8 @@ function on_error { |
|
|
|
failure_code="${1:-200}" |
|
|
|
>&4 printf '\r' # TODO: force carriage return explicitly, is it really useful? |
|
|
|
|
|
|
|
miaou_debug "<on_error code=${failure_code} command=[${BASH_COMMAND}]>" |
|
|
|
|
|
|
|
if [[ $$ == "$BASHPID" ]]; then |
|
|
|
if [[ ! -v failure_type ]]; then |
|
|
|
if [[ ${BASH_COMMAND} == 'false' ]]; then |
|
|
|
@ -116,12 +118,6 @@ function on_error { |
|
|
|
print_miaou_error "${BASH_SOURCE[1]}" "${BASH_LINENO[0]}" "${failure_code}" "${failure_type}" |
|
|
|
fi |
|
|
|
|
|
|
|
if [[ -v failure_payload ]]; then |
|
|
|
miaou_debug "<on_error exit=$failure_code type=${failure_type} payload=${failure_payload} />" |
|
|
|
else |
|
|
|
miaou_debug "<on_error exit=$failure_code type=${failure_type} />" |
|
|
|
fi |
|
|
|
|
|
|
|
error_source=("${BASH_SOURCE[@]}") |
|
|
|
error_lineno=("${BASH_LINENO[@]}") |
|
|
|
error_funcname=("${FUNCNAME[@]}") |
|
|
|
@ -132,9 +128,15 @@ function on_error { |
|
|
|
error_lineno=("${error_lineno[@]}") |
|
|
|
error_funcname=("${error_funcname[@]}") |
|
|
|
|
|
|
|
if [[ -v failure_payload ]]; then |
|
|
|
miaou_debug "</on_error exit=$failure_code type=${failure_type} payload=${failure_payload}>" |
|
|
|
else |
|
|
|
miaou_debug "</on_error exit=$failure_code type=${failure_type}>" |
|
|
|
fi |
|
|
|
|
|
|
|
builtin exit "$failure_code" |
|
|
|
else |
|
|
|
miaou_debug "<on_error pipe=$failure_code sub_pid=$BASHPID pid=$$ command='${BASH_COMMAND}'/>" |
|
|
|
miaou_debug "</on_error pipe=$failure_code sub_pid=$BASHPID pid=$$ command='${BASH_COMMAND}'>" |
|
|
|
print_miaou_error "${BASH_SOURCE[1]}" "${BASH_LINENO[0]}" "${failure_code}" 'SUBSHELL_ERROR' "${BASH_COMMAND}" |
|
|
|
kill -PIPE $$ |
|
|
|
fi |
|
|
|
|