colored hint message
This commit is contained in:
+18
-1
@@ -370,14 +370,31 @@ function dump_stacktrace {
|
|||||||
for i in "${!error_source[@]}"; do
|
for i in "${!error_source[@]}"; do
|
||||||
tty_ansi FG_MAGENTA
|
tty_ansi FG_MAGENTA
|
||||||
echo -n " ╟──▷"
|
echo -n " ╟──▷"
|
||||||
[[ $i -gt 0 ]] && tty_ansi FG_GRAY
|
|
||||||
tty_ansi STYLE_ITALIC
|
tty_ansi STYLE_ITALIC
|
||||||
source="${error_source[$i]}"
|
source="${error_source[$i]}"
|
||||||
lineno="${error_lineno[$i]}"
|
lineno="${error_lineno[$i]}"
|
||||||
funcname="${error_funcname[$i]}"
|
funcname="${error_funcname[$i]}"
|
||||||
|
|
||||||
|
local hint regex='(^.*) \(hint: (.*)\)$'
|
||||||
|
if [[ "$funcname" =~ $regex ]]; then
|
||||||
|
hint="${BASH_REMATCH[2]}"
|
||||||
|
funcname="${BASH_REMATCH[1]} (hint: "
|
||||||
|
else
|
||||||
|
unset hint
|
||||||
|
[[ $i -gt 0 ]] && tty_ansi FG_GRAY
|
||||||
|
fi
|
||||||
|
|
||||||
printf "%40s:%.4s" "$source" "$lineno"
|
printf "%40s:%.4s" "$source" "$lineno"
|
||||||
tty_ansi RESET
|
tty_ansi RESET
|
||||||
printf " \t%s" "$funcname"
|
printf " \t%s" "$funcname"
|
||||||
|
|
||||||
|
if [[ -v hint ]]; then
|
||||||
|
tty_ansi FG_YELLOW
|
||||||
|
printf "$hint"
|
||||||
|
tty_ansi RESET
|
||||||
|
printf ')'
|
||||||
|
fi
|
||||||
|
|
||||||
echo
|
echo
|
||||||
done
|
done
|
||||||
miaou_debug '</stacktrace>'
|
miaou_debug '</stacktrace>'
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ fail_type exit EXIT
|
|||||||
fail_type command_not_found COMMAND_NOT_FOUND
|
fail_type command_not_found COMMAND_NOT_FOUND
|
||||||
fail_type source_not_found SOURCE_NOT_FOUND
|
fail_type source_not_found SOURCE_NOT_FOUND
|
||||||
fail_type file_not_found FILE_NOT_FOUND
|
fail_type file_not_found FILE_NOT_FOUND
|
||||||
fail_type child_error CHILD_ERROR '(hint: prefer source than child process)'
|
fail_type child_error CHILD_ERROR 'prefer source than child process'
|
||||||
|
|
||||||
failed=${#failures[@]}
|
failed=${#failures[@]}
|
||||||
success=$((test_count - failed))
|
success=$((test_count - failed))
|
||||||
|
|||||||
Reference in New Issue
Block a user