Merge "Add call trace in error message"

This commit is contained in:
Jenkins 2013-08-08 15:45:49 +00:00 committed by Gerrit Code Review
commit dedc4617a7

View File

@ -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
}