func exitError for consistent error logging

This commit is contained in:
Asif Bacchus 2019-05-23 23:07:44 -06:00
parent 2b8941da51
commit 9e335224a0

View File

@ -35,6 +35,19 @@ badParam () {
fi fi
} }
exitError () {
errCode="error_$1"
eval errReport='$'"$errCode"
if [ -n "$errReport" ]; then
printf "${err}[%s] -- [ERROR] %s: %s --${norm}\n" \
"$(stamp)" "$1" "$errReport" >> "$logFile"
else
printf "${err}[%s] -- [ERROR] Unknown error code reported --${norm}\n" \
"$(stamp)" >> "$logFile"
fi
exit "$1"
}
# control seafile services (systemd) # control seafile services (systemd)
seafSvc () { seafSvc () {
if [ "$1" = "start" ]; then if [ "$1" = "start" ]; then