Last active
August 29, 2015 14:16
-
-
Save gaqzi/2f30ebc292b7cdcb3e52 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function if-error() { | |
local exit_status="$1" | |
local error_code="$2" | |
local error_message="${@:3}" | |
if [ "$exit_status" -ne 0 ] ; then | |
log-message "(error: $error_code) $error_message" | |
exit $error_code | |
fi | |
} | |
function log-message() { | |
local message="${@}" | |
local script="$(basename $0)" | |
echo "[$script] $message" | tee -a $LOG_FILE | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment