Skip to content

Instantly share code, notes, and snippets.

@gaqzi
Last active August 29, 2015 14:16
Show Gist options
  • Save gaqzi/2f30ebc292b7cdcb3e52 to your computer and use it in GitHub Desktop.
Save gaqzi/2f30ebc292b7cdcb3e52 to your computer and use it in GitHub Desktop.
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