New function to display exceptions

This commit is contained in:
Michael Boelen 2019-08-21 14:50:32 +02:00
parent 7eba5df9b2
commit 4e39bafd78
No known key found for this signature in database
GPG Key ID: 26141F77A09D7F04
1 changed files with 39 additions and 1 deletions

View File

@ -40,6 +40,7 @@
# DiscoverProfiles Determine available profiles on system
# Display Output text to screen with colors and identation
# DisplayError Show an error on screen
# DisplayException Show an exception on screen
# DisplayManual Output text to screen without any layout
# DisplayToolTip Show a tip for improving usage of the tool
# DisplayWarning Show a clear warning on screen
@ -656,6 +657,40 @@
}
################################################################################
# Name : DisplayException()
# Description : Show a discovered exception on screen
#
# Parameters : $1 = function or test
# $2 = text
# Returns : <nothing>
# Note : This function is usually triggered by ReportException
################################################################################
DisplayException() {
${ECHOCMD:-echo} ""
${ECHOCMD:-echo} "================================================================="
${ECHOCMD:-echo} ""
${ECHOCMD:-echo} " ${WARNING}Exception found!${NORMAL}"
${ECHOCMD:-echo} ""
${ECHOCMD:-echo} " Function/test: [$1]"
${ECHOCMD:-echo} " Message: ${BOLD}$2${NORMAL}"
${ECHOCMD:-echo} ""
${ECHOCMD:-echo} " Help improving the Lynis community with your feedback!"
${ECHOCMD:-echo} ""
${ECHOCMD:-echo} " Steps:"
${ECHOCMD:-echo} " - Ensure you are running the latest version ($0 update check)"
${ECHOCMD:-echo} " - If so, create a GitHub issue at ${PROGRAM_SOURCE}"
${ECHOCMD:-echo} " - Include relevant parts of the log file or configuration file"
${ECHOCMD:-echo} ""
${ECHOCMD:-echo} " Thanks!"
${ECHOCMD:-echo} ""
${ECHOCMD:-echo} "================================================================="
${ECHOCMD:-echo} ""
sleep 5
}
################################################################################
# Name : DisplayManual()
# Description : Show text on screen, without any markup
@ -1429,7 +1464,7 @@
################################################################################
IsDeveloperVersion() {
if [ "${PROGRAM_RELEASE_TYPE}" = "dev" ]; then return 0; else return 1; fi
if [ "${PROGRAM_RELEASE_TYPE}" = "pre-release" ]; then return 0; else return 1; fi
}
@ -2764,6 +2799,9 @@
ReportException() {
Report "exception_event[]=$1|${2-NoInfo}|"
LogText "Exception: test has an exceptional event ($1) with text ${2-NoText}"
if [ ${QUIET} -eq 0 ]; then
DisplayException "$1" "$2"
fi
}