# limitations under the License.
-
# Commentary: Bash stack trace and error handling functions. This file
# is meant to be sourced. It loads some functions which you may want to
# call manually (see the comments at the start of each one), and then
# help: turn off exit and stack trace on error. undoes err-catch
set +E +o pipefail; trap ERR
}
+
err-bash-trace() {
# help: print stack trace
#
echo \'
done
}
+
err-catch() {
- # help: print stack trace and exit on error.
+ # help: on errors: print stack trace and exit
#
- # Set "${_errcatch_cleanup[@]}" to set a command which will run before exiting.
+ # You can set "${_errcatch_cleanup[@]}" to a command and it will run before exiting.
# This function depends on err-bash-trace.
set -E; shopt -s extdebug
trap _err-trap ERR
set -o pipefail
}
+
err-exit() {
# usage: err-exit [EXIT_CODE] [MESSAGE]
# help: exit and print stack trace.
echo "$0: exiting with code $code"
exit $err
}
+
err-catch