Skip to content

Commit 23b670d

Browse files
committed
Provide traceback on error exit when debugging or running tests
More breadcrumbs.
1 parent 519aafd commit 23b670d

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

getssl

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@
265265
# 2021-07-20 Use +noidnout to enable certificates for IDN domains (#679)(2.37)
266266
# 2021-07-22 Only pass +noidnout param to dig/drill(#682)(2.38)
267267
# 2021-07-25 Fix copy_file_to_location failures with ssh when suffix applied to file lacking an extension (tlhackque)(#686)
268-
# 2021-07-27 Support ftps://, FTPS_OPTIONS, remove default --insecure parameter to ftpes. Report caller of error_exit in debug and test modes (tlhackque)(#687)(2.39)
268+
# 2021-07-27 Support ftps://, FTPS_OPTIONS, remove default --insecure parameter to ftpes. Report caller(s) of error_exit in debug and test modes (tlhackque)(#687)(2.39)
269269
# ----------------------------------------------------------------------------------------
270270

271271
case :$SHELLOPTS: in
@@ -1161,7 +1161,7 @@ test_output() { # write out debug output for testing
11611161
error_exit() { # give error message on error exit
11621162
echo -e "${PROGNAME}: ${1:-"Unknown Error"}" >&2
11631163
if [[ ${_RUNNING_TEST} -eq 1 ]] || [[ ${_USE_DEBUG} -eq 1 ]] ; then
1164-
echo " from ${FUNCNAME[1]}:${BASH_LINENO[1]}" >&2
1164+
traceback
11651165
fi
11661166
clean_up
11671167
exit 1
@@ -2413,6 +2413,16 @@ signal_exit() { # Handle trapped signals
24132413
esac
24142414
}
24152415

2416+
traceback() { # Print function traceback
2417+
local i d=1 lbl=" called"
2418+
echo "Traceback" >&2
2419+
for ((i=$((${#FUNCNAME[@]}-1)); i>0; i--)); do
2420+
if [[ ${i} -eq 1 ]] ; then lbl=" called traceback" ; fi
2421+
printf "%*s%s() line %d%s\n" "$d" '' "${FUNCNAME[$i]}" "${BASH_LINENO[$((i-1))]}" "$lbl" >&2
2422+
((d++))
2423+
done
2424+
}
2425+
24162426
urlbase64() { # urlbase64: base64 encoded string with '+' replaced with '-' and '/' replaced with '_'
24172427
openssl base64 -e | tr -d '\n\r' | os_esed -e 's:=*$::g' -e 'y:+/:-_:'
24182428
}

0 commit comments

Comments
 (0)