|
|
|
@ -95,6 +95,7 @@ function on_exit { |
|
|
|
failure_payload="${BASH_REMATCH[2]}" |
|
|
|
fi |
|
|
|
last_error="${BASH_SOURCE[1]}:${BASH_LINENO[0]} subshell term $code" |
|
|
|
printf "\r" |
|
|
|
kill -USR1 $$ |
|
|
|
else |
|
|
|
failure_type='UNKNOWN' |
|
|
|
@ -217,9 +218,12 @@ function ansi_block_error { |
|
|
|
content=$(style_padding "$content") |
|
|
|
detail=$(BG=BLACK style_padding "$2") |
|
|
|
exit_code=$(FG=CYAN style_ansi " $3") |
|
|
|
style_block "$content$detail$exit_code" |
|
|
|
|
|
|
|
printf "\r" |
|
|
|
BLOCK_CONTINUATION_COL=5 style_block "$content$detail$exit_code" |
|
|
|
# echo "$content$detail$exit_code" |
|
|
|
ansi_reset |
|
|
|
FG=RED style_ansi " ║" |
|
|
|
echo |
|
|
|
} |
|
|
|
|
|
|
|
function ansi_traces { |
|
|
|
@ -229,31 +233,31 @@ function ansi_traces { |
|
|
|
declare -n functions=$3 |
|
|
|
optional=false |
|
|
|
for i in "${!sources[@]}"; do |
|
|
|
FG=RED style_ansi "\t╟─⟶" |
|
|
|
location="${sources[$i]}:${lines[$i]}" |
|
|
|
FG=RED style_ansi " ╟─⟶" |
|
|
|
location=$(printf "%40s" "${sources[$i]}:${lines[$i]}") |
|
|
|
is_true "$optional" && |
|
|
|
location=$(FG=GRAY STYLE=ITALIC style_ansi "\t$location") || # FIXME: \t should not be required! |
|
|
|
location=$(FG=GRAY STYLE=ITALIC style_ansi "$location") || |
|
|
|
location=$(STYLE=ITALIC style_ansi "$location") |
|
|
|
printf "%40s\t%s\n" "${location}" "${functions[$i]}" |
|
|
|
builtin echo "${location} ${functions[$i]}" |
|
|
|
optional=true |
|
|
|
done |
|
|
|
} |
|
|
|
function dump_failure { |
|
|
|
declare -F style_ansi >/dev/null || source "$MIAOU_BASH_DIR/lib/ansi.bash" |
|
|
|
dump_stderr true |
|
|
|
debug '---stacktrace---' |
|
|
|
if [[ ${failure_type} == 'SUBSHELL SOURCE NOT FOUND' ]]; then |
|
|
|
: |
|
|
|
else |
|
|
|
debug '---error---' |
|
|
|
if [[ $failure_type == 'SUBSHELL ERROR' ]]; then |
|
|
|
>&4 echo -e "${failure_payload}" |
|
|
|
else |
|
|
|
declare -F style_ansi >/dev/null || source "$MIAOU_BASH_DIR/lib/ansi.bash" |
|
|
|
>&4 ansi_block_error "$failure_type" "$failure_payload" "$code" |
|
|
|
>&4 ansi_block_continuation |
|
|
|
fi |
|
|
|
debug '---end of error---' |
|
|
|
fi |
|
|
|
|
|
|
|
declare -F style_ansi >/dev/null || source "$MIAOU_BASH_DIR/lib/ansi.bash" |
|
|
|
debug '---stacktrace---' |
|
|
|
>&4 ansi_traces stack_sources stack_lines stack_functions |
|
|
|
|
|
|
|
# for i in "${failure_traces[@]}"; do |
|
|
|
@ -269,6 +273,7 @@ function dump_stderr { |
|
|
|
is_true "$last_trim" && unset 'tmp_error[-1]' && tmp_error=("${tmp_error[@]}") |
|
|
|
if [[ "${#tmp_error[@]}" -gt 0 ]]; then |
|
|
|
debug '---stderr---' |
|
|
|
>&4 printf '\r' |
|
|
|
for i in "${tmp_error[@]}"; do |
|
|
|
>&4 echo -e "$i" |
|
|
|
done |
|
|
|
|