You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
521 B
24 lines
521 B
# shellcheck shell=bash
|
|
if [ -n "$__panic_sh__" ]; then return; fi
|
|
__panic_sh__=$(date)
|
|
|
|
source "error_msg.sh" || exit 1
|
|
|
|
declare __common_did_dump_callstack=false
|
|
|
|
__common_dump_callstack() {
|
|
echo "Call Stack:"
|
|
for ((i = 1; i < ${#FUNCNAME[@]}; i++)); do
|
|
printf "\t%d - %s\n" "$((i - 1))" "${FUNCNAME[i]} (${BASH_SOURCE[i + 1]}:${BASH_LINENO[i]})"
|
|
done
|
|
}
|
|
|
|
# Public API
|
|
panic() {
|
|
error_msg "${@}"
|
|
[[ "$__common_did_dump_callstack" == false ]] && {
|
|
__common_dump_callstack
|
|
__common_did_dump_callstack=true
|
|
}
|
|
}
|