|
|
@ -96,8 +96,8 @@ function tty_ansi { |
|
|
|
|
|
|
|
|
function print_miaou_error { |
|
|
function print_miaou_error { |
|
|
local source="$1" line="$2" code="$3" type="$4" payload="${5:-}" |
|
|
local source="$1" line="$2" code="$3" type="$4" payload="${5:-}" |
|
|
>&2 echo -n "${source}: line ${line}: miaou_error: code=${code} type=${type}" |
|
|
|
|
|
[[ -n "$payload" ]] && >&2 echo " payload=${payload}" || >&2 echo |
|
|
|
|
|
|
|
|
>&2 echo -n "${source}: line ${line}: miaou_error: ${type} ${code}" |
|
|
|
|
|
[[ -n "$payload" ]] && >&2 echo " payload: ${payload}" || >&2 echo |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function on_error { |
|
|
function on_error { |
|
|
@ -134,8 +134,8 @@ function on_error { |
|
|
|
|
|
|
|
|
builtin exit "$failure_code" |
|
|
builtin exit "$failure_code" |
|
|
else |
|
|
else |
|
|
miaou_debug "<on_error pipe=$failure_code sub_pid=$BASHPID pid=$$/>" |
|
|
|
|
|
print_miaou_error "${BASH_SOURCE[1]}" "${BASH_LINENO[0]}" "${failure_code}" 'SUBSHELL_ERROR' |
|
|
|
|
|
|
|
|
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 $$ |
|
|
kill -PIPE $$ |
|
|
fi |
|
|
fi |
|
|
} |
|
|
} |
|
|
@ -153,13 +153,13 @@ function on_pipe { |
|
|
|
|
|
|
|
|
mapfile -t tmp_error <"$MIAOU_BASH_ERROR" |
|
|
mapfile -t tmp_error <"$MIAOU_BASH_ERROR" |
|
|
last_error="${tmp_error[-1]}" |
|
|
last_error="${tmp_error[-1]}" |
|
|
regex='(.*): line ([0-9]+): miaou_error: code=([0-9]+) type=SUBSHELL_ERROR' |
|
|
|
|
|
|
|
|
regex='^(.*): line ([0-9]+): miaou_error: SUBSHELL_ERROR ([0-9]+) payload: (.*)$' |
|
|
if [[ $last_error =~ $regex ]]; then |
|
|
if [[ $last_error =~ $regex ]]; then |
|
|
source=${BASH_REMATCH[1]} |
|
|
source=${BASH_REMATCH[1]} |
|
|
lineno=${BASH_REMATCH[2]} |
|
|
lineno=${BASH_REMATCH[2]} |
|
|
failure_code=${BASH_REMATCH[3]} |
|
|
failure_code=${BASH_REMATCH[3]} |
|
|
|
|
|
failure_payload=${BASH_REMATCH[4]} |
|
|
failure_type="SUBSHELL_ERROR" |
|
|
failure_type="SUBSHELL_ERROR" |
|
|
failure_payload='...' |
|
|
|
|
|
error_source=("$source" "${error_source[@]}") |
|
|
error_source=("$source" "${error_source[@]}") |
|
|
error_lineno=("$lineno" "${error_lineno[@]}") |
|
|
error_lineno=("$lineno" "${error_lineno[@]}") |
|
|
error_funcname=("${error_funcname[@]}" '<main>') |
|
|
error_funcname=("${error_funcname[@]}" '<main>') |
|
|
@ -231,7 +231,7 @@ function on_exit { |
|
|
2>&3 >&3 dump_stderr |
|
|
2>&3 >&3 dump_stderr |
|
|
if [[ -v failure_type && "$failure_type" == 'RETURN' ]]; then |
|
|
if [[ -v failure_type && "$failure_type" == 'RETURN' ]]; then |
|
|
last_error="${tmp_error[-1]}" |
|
|
last_error="${tmp_error[-1]}" |
|
|
regex='^(.*): line ([0-9]+): miaou_error: code=[0-9]+ type=RETURN' |
|
|
|
|
|
|
|
|
regex='^(.*): line ([0-9]+): miaou_error: RETURN [0-9]+' |
|
|
if [[ "$last_error" =~ $regex ]]; then |
|
|
if [[ "$last_error" =~ $regex ]]; then |
|
|
miaou_debug "<return exit=$code />" |
|
|
miaou_debug "<return exit=$code />" |
|
|
local source line |
|
|
local source line |
|
|
|