Browse Source

unkown error box

main
pvincent 2 weeks ago
parent
commit
63ff704445
  1. 24
      poc

24
poc

@ -246,12 +246,19 @@ function dump_failure {
printf "%5s" " $failure_code "
tty_ansi FG_MAGENTA
echo "║"
if [[ ! -v error_source ]]; then
echo -n '╚'
for ((i = 0; i < length_box; i++)); do echo -n '═'; done
echo '╝'
else
echo -n '╚'
for ((i = 0; i < 4; i++)); do echo -n '═'; done
echo -n '╦'
for ((i = 5; i < length_box; i++)); do echo -n '═'; done
echo '╝'
echo " ║"
fi
tty_ansi RESET
miaou_debug '</error_box>'
}
@ -289,8 +296,9 @@ function load_tmp_error {
function on_exit {
trap - RETURN
local code="${1:-0}" last_error regex
miaou_debug "<on_exit code=$code>"
failure_code="${1:-0}"
local last_error regex
miaou_debug "<on_exit code=$failure_code>"
load_tmp_error
@ -298,7 +306,7 @@ function on_exit {
last_error="${tmp_error[-1]}"
regex='^(.*): line ([0-9]+): miaou_error: RETURN [0-9]+'
if [[ "$last_error" =~ $regex ]]; then
miaou_debug "<return code=$code/>"
miaou_debug "<return code=$failure_code/>"
local source line
source="${BASH_REMATCH[1]}"
line="${BASH_REMATCH[2]}"
@ -314,12 +322,12 @@ function on_exit {
add_miaou_error "${BASH_SOURCE[1]}" "${BASH_LINENO[0]}" "${failure_code}" "${failure_type}" "${failure_payload}"
miaou_debug '<command_not_found change_stderr />'
elif [[ ! -v failure_type ]]; then
if [[ $code -gt 0 && ${#tmp_error[@]} -gt 0 ]]; then
if [[ $failure_code -gt 0 && ${#tmp_error[@]} -gt 0 ]]; then
last_error="${tmp_error[-1]}"
miaou_debug "<investigate_tmp_error last={$last_error}>"
regex='^(.*): line ([0-9]+): (.*): unbound variable$'
if [[ $code -eq 1 ]] && [[ "$last_error" =~ $regex ]]; then
if [[ $failure_code -eq 1 ]] && [[ "$last_error" =~ $regex ]]; then
local source line payload
source="${BASH_REMATCH[1]}"
@ -335,7 +343,7 @@ function on_exit {
error_lineno=("$line" "${error_lineno[@]}")
error_funcname=("${error_funcname[@]}" '<main>')
failure_code=$code
failure_code=$failure_code
failure_type='UNBOUND_VARIABLE'
failure_payload=$payload
@ -352,9 +360,11 @@ function on_exit {
2>&3 >&3 dump_stderr
if [[ -v failure_type ]]; then
2>&3 >&4 dump_failure
if [[ -v error_source ]]; then
2>&3 >&4 dump_stacktrace
fi
if [[ $code -gt 0 ]]; then
fi
if [[ $failure_code -gt 0 ]]; then
miaou_debug "</on_exit failure>"
else
miaou_debug "</on_exit success>"

Loading…
Cancel
Save