From 53aa7b73d39cac88a02f4f21c443a13550b308fc Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Sun, 15 Jan 2017 07:35:43 -0800 Subject: [PATCH] add custom error handler ability --- errcatch-function | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/errcatch-function b/errcatch-function index bf60d0c..4fb8c37 100644 --- a/errcatch-function +++ b/errcatch-function @@ -13,6 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. + +# runs "${_errcatch_cleanup[@]}" for caller defined error handling. +# While running that, we exit with set -e, no stack trace, as +# err trap does not work within an error trap + errcatch() { set -E; shopt -s extdebug _err-trap() { @@ -21,6 +26,8 @@ errcatch() { set +x echo "${BASH_SOURCE[1]}:${BASH_LINENO[0]}:in \`$BASH_COMMAND' returned $err" bash-trace 2 + set -e + "${_errcatch_cleanup[@]}" echo "$0: exiting with code $err" exit $err } -- 2.25.1