Browse Source

split this into 2 functions

master
belliash 9 years ago
parent
commit
78760a6b63
1 changed files with 14 additions and 6 deletions
  1. +14
    -6
      libraries/common

+ 14
- 6
libraries/common View File

@ -51,12 +51,7 @@ function checkVersion() {
# Parameters: %message% %code%
#-------------------------------------------------------------------------------
function die() {
if isEnabled ${LOGGING} && isSet NOTIFY && isEnabled ${EZNOTIFY}; 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
notify "${1}" ${2}
printError "${1}"
echo -ne "\n"
exit ${2}
@ -171,6 +166,19 @@ function logOutput() {
fi
}
#-------------------------------------------------------------------------------
# Sends an e-mail notification about occured error
# Parameters: %message% %code%
#-------------------------------------------------------------------------------
function notify() {
if isEnabled ${LOGGING} && isSet NOTIFY && isEnabled ${EZNOTIFY}; 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
}
#-------------------------------------------------------------------------------
# Outputs error message and aborts program execution
#-------------------------------------------------------------------------------

Loading…
Cancel
Save