Add test shell stack traces

This commit is contained in:
Jordan Liggitt
2017-01-25 11:26:23 -05:00
parent d47f898500
commit a7f52b276f
2 changed files with 27 additions and 9 deletions

View File

@@ -28,7 +28,16 @@ kube::log::errexit() {
set +o xtrace
local code="${1:-1}"
kube::log::error_exit "'${BASH_COMMAND}' exited with status $err" "${1:-1}" 1
# Print out the stack trace described by $function_stack
if [ ${#FUNCNAME[@]} -gt 2 ]
then
kube::log::error "Call tree:"
for ((i=1;i<${#FUNCNAME[@]}-1;i++))
do
kube::log::error " $i: ${BASH_SOURCE[$i+1]}:${BASH_LINENO[$i]} ${FUNCNAME[$i]}(...)"
done
fi
kube::log::error_exit "Error in ${BASH_SOURCE[1]}:${BASH_LINENO[0]}. '${BASH_COMMAND}' exited with status $err" "${1:-1}" 1
}
kube::log::install_errexit() {