implement die()

This commit is contained in:
belliash 2011-12-30 21:37:46 +01:00
parent 4e982538d7
commit bd1ee52278
1 changed files with 15 additions and 0 deletions

View File

@ -3,6 +3,21 @@
# Distributed under the terms of the GNU General Public License v3
#-------------------------------------------------------------------------------
# Outputs formatted error message and aborts script execution with given code
# Parameters: %message% %code%
#-------------------------------------------------------------------------------
function die() {
if isEnabled ${LOGGING} && isSet NOTIFY; then
local LOGS="Full output from logs:\n\n$(cat ${LOGFILE})"
local MESG="The ${EZNAME} has failed with code: ${2} and message: ${1}"
local TOPIC="The ${EZNAME} process has failed!"
echo -e "${MESG}\n${LOGS}" | mailx -s "${TOPIC}" "${NOTIFY}"
fi
printError "${1}"
exit ${2}
}
#-------------------------------------------------------------------------------
# Checks whether a supplied variable is defined or not
# Parameters: %variable%