mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2026-02-03 04:09:29 -05:00
Improves error/exception handling
This commit is contained in:
parent
87a9d126d2
commit
438bd86985
2 changed files with 15 additions and 7 deletions
|
|
@ -25,8 +25,13 @@ function Exit-IcingaThrowCritical()
|
|||
Set-IcingaInternalPluginExitCode -ExitCode $IcingaEnums.IcingaExitCode.Critical;
|
||||
Set-IcingaInternalPluginException -PluginException $OutputMessage;
|
||||
|
||||
if ($Global:Icinga.Protected.RunAsDaemon -eq $FALSE -And $Global:Icinga.Protected.JEAContext -eq $FALSE) {
|
||||
Write-IcingaConsolePlain $OutputMessage;
|
||||
exit $IcingaEnums.IcingaExitCode.Critical;
|
||||
if ($Global:Icinga.Protected.RunAsDaemon -eq $TRUE -Or $Global:Icinga.Protected.JEAContext -eq $TRUE) {
|
||||
throw $OutputMessage;
|
||||
|
||||
# Just in case we don't end - shouldn't happen anyway
|
||||
return;
|
||||
}
|
||||
|
||||
Write-IcingaConsolePlain $OutputMessage;
|
||||
exit $IcingaEnums.IcingaExitCode.Critical;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,10 +110,13 @@ function Exit-IcingaThrowException()
|
|||
Set-IcingaInternalPluginExitCode -ExitCode $IcingaEnums.IcingaExitCode.Unknown;
|
||||
Set-IcingaInternalPluginException -PluginException $OutputMessage;
|
||||
|
||||
if ($Global:Icinga.Protected.RunAsDaemon -eq $FALSE -And $Global:Icinga.Protected.JEAContext -eq $FALSE) {
|
||||
Write-IcingaConsolePlain $OutputMessage;
|
||||
exit $IcingaEnums.IcingaExitCode.Unknown;
|
||||
} else {
|
||||
if ($Global:Icinga.Protected.RunAsDaemon -eq $TRUE -Or $Global:Icinga.Protected.JEAContext -eq $TRUE) {
|
||||
throw $OutputMessage;
|
||||
|
||||
# Just in case we don't end - shouldn't happen anyway
|
||||
return;
|
||||
}
|
||||
|
||||
Write-IcingaConsolePlain $OutputMessage;
|
||||
exit $IcingaEnums.IcingaExitCode.Unknown;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue