Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'production/miscToolsAndNotes/misc/checkForErrorExit.sh')
-rwxr-xr-xproduction/miscToolsAndNotes/misc/checkForErrorExit.sh29
1 files changed, 29 insertions, 0 deletions
diff --git a/production/miscToolsAndNotes/misc/checkForErrorExit.sh b/production/miscToolsAndNotes/misc/checkForErrorExit.sh
new file mode 100755
index 00000000..06cbdfa6
--- /dev/null
+++ b/production/miscToolsAndNotes/misc/checkForErrorExit.sh
@@ -0,0 +1,29 @@
+
+# TODO: an enhanced version was put directly in 'wgetFreshSDKdir.sh'
+# Should check if this is used anywhere, and delete, if not.
+
+function checkForErrorExit ()
+{
+ # arg 1 must be return code, $?
+ # arg 2 (remaining line) can be message to print before exiting due to non-zero exit code
+ exitCode=$1
+ shift
+ message="$*"
+ if [ -z "${exitCode}" ]
+ then
+ echo "PROGRAM ERROR: checkForErrorExit called with no arguments"
+ exit 1
+ fi
+ if [ -z "${message}" ]
+ then
+ echo "WARNING: checkForErrorExit called without message"
+ message="(Calling program provided no message)"
+ fi
+ if [ "${exitCode}" -ne "0" ]
+ then
+ echo
+ echo " ERROR. exit code: ${exitCode} ${message}"
+ echo
+ exit "${exitCode}"
+ fi
+}

Back to the top