1.1 --- a/scripts/functions Fri Apr 08 00:02:44 2011 +0200
1.2 +++ b/scripts/functions Tue May 10 23:56:11 2011 +0200
1.3 @@ -4,19 +4,53 @@
1.4
1.5 # Prepare the fault handler
1.6 CT_OnError() {
1.7 - ret=$?
1.8 + local ret=$?
1.9 + local intro
1.10 + local file
1.11 + local line
1.12 + local func
1.13 + local step_depth
1.14 +
1.15 # Bail out early in subshell, the upper level shell will act accordingly.
1.16 [ ${BASH_SUBSHELL} -eq 0 ] || exit $ret
1.17 +
1.18 + # Print steps backtrace
1.19 + step_depth=${CT_STEP_COUNT}
1.20 + CT_STEP_COUNT=2
1.21 + CT_DoLog ERROR ""
1.22 + intro="Build failed"
1.23 + for((step=step_depth; step>1; step--)); do
1.24 + CT_DoLog ERROR ">> ${intro} in step '${CT_STEP_MESSAGE[${step}]}'"
1.25 + intro=" called"
1.26 + done
1.27 +
1.28 + # Print functions backtrace
1.29 + intro="Error happened in"
1.30 + offset=1
1.31 + CT_DoLog ERROR ">>"
1.32 + for((depth=1; ${BASH_LINENO[$((${depth}-1))]}>0; depth++)); do
1.33 + file="${BASH_SOURCE[${depth}]#${CT_LIB_DIR}/}"
1.34 + case "${depth}" in
1.35 + 1) line="";;
1.36 + *) line="@${BASH_LINENO[${depth}-1]}"
1.37 + esac
1.38 + func="${FUNCNAME[${depth}]}"
1.39 + CT_DoLog ERROR ">> ${intro}: ${func}[${file}${line}]"
1.40 + intro=" called from"
1.41 + done
1.42 +
1.43 + # Help diagnose the error
1.44 + CT_DoLog ERROR ">>"
1.45 + if [ "${CT_LOG_TO_FILE}" = "y" ]; then
1.46 + CT_DoLog ERROR ">> For more info on this error, look at the file: '${tmp_log_file#${CT_TOP_DIR}/}'"
1.47 + fi
1.48 + CT_DoLog ERROR ">> There is a list of known issues, some with workarounds, in:"
1.49 + CT_DoLog ERROR ">> '${CT_DOC_DIR#${CT_TOP_DIR}/}/B - Known issues.txt'"
1.50 +
1.51 + CT_DoLog ERROR ""
1.52 CT_DoLog ERROR "Build failed in step '${CT_STEP_MESSAGE[${CT_STEP_COUNT}]}'"
1.53 - for((step=(CT_STEP_COUNT-1); step>1; step--)); do
1.54 - CT_DoLog ERROR " called in step '${CT_STEP_MESSAGE[${step}]}'"
1.55 - done
1.56 - CT_DoLog ERROR "Error happened in '${BASH_SOURCE[1]}' in function '${FUNCNAME[1]}' (line unknown, sorry)"
1.57 - for((depth=2; ${BASH_LINENO[$((${depth}-1))]}>0; depth++)); do
1.58 - CT_DoLog ERROR " called from '${BASH_SOURCE[${depth}]}' at line # ${BASH_LINENO[${depth}-1]} in function '${FUNCNAME[${depth}]}'"
1.59 - done
1.60 - [ "${CT_LOG_TO_FILE}" = "y" ] && CT_DoLog ERROR "Look at '${tmp_log_file}' for more info on this error."
1.61 - CT_STEP_COUNT=1
1.62 +
1.63 + CT_DoLog ERROR ""
1.64 CT_DoEnd ERROR
1.65 exit $ret
1.66 }