From 78760a6b636d3273a5e3a99caa6eae7915cbbf43 Mon Sep 17 00:00:00 2001 From: belliash Date: Thu, 12 Jan 2012 12:16:48 +0100 Subject: [PATCH] split this into 2 functions --- libraries/common | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/libraries/common b/libraries/common index 6f8a8f9..e0e6d9f 100644 --- a/libraries/common +++ b/libraries/common @@ -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 #-------------------------------------------------------------------------------