Merge "Add call trace in error message"
This commit is contained in:
commit
dedc4617a7
14
functions
14
functions
@ -76,6 +76,19 @@ function cp_it {
|
||||
}
|
||||
|
||||
|
||||
# Prints backtrace info
|
||||
# filename:lineno:function
|
||||
function backtrace {
|
||||
local level=$1
|
||||
local deep=$((${#BASH_SOURCE[@]} - 1))
|
||||
echo "[Call Trace]"
|
||||
while [ $level -le $deep ]; do
|
||||
echo "${BASH_SOURCE[$deep]}:${BASH_LINENO[$deep-1]}:${FUNCNAME[$deep-1]}"
|
||||
deep=$((deep - 1))
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
# Prints line number and "message" then exits
|
||||
# die $LINENO "message"
|
||||
function die() {
|
||||
@ -85,6 +98,7 @@ function die() {
|
||||
if [ $exitcode == 0 ]; then
|
||||
exitcode=1
|
||||
fi
|
||||
backtrace 2
|
||||
err $line "$*"
|
||||
exit $exitcode
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user