mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2026-02-03 12:19:29 -05:00
Merge pull request #647 from Icinga:fix/improve_exception_and_error_handling
Feature: Improves error/exception handling
This commit is contained in:
commit
7ed21189c0
2 changed files with 15 additions and 7 deletions
|
|
@ -25,8 +25,13 @@ function Exit-IcingaThrowCritical()
|
||||||
Set-IcingaInternalPluginExitCode -ExitCode $IcingaEnums.IcingaExitCode.Critical;
|
Set-IcingaInternalPluginExitCode -ExitCode $IcingaEnums.IcingaExitCode.Critical;
|
||||||
Set-IcingaInternalPluginException -PluginException $OutputMessage;
|
Set-IcingaInternalPluginException -PluginException $OutputMessage;
|
||||||
|
|
||||||
if ($Global:Icinga.Protected.RunAsDaemon -eq $FALSE -And $Global:Icinga.Protected.JEAContext -eq $FALSE) {
|
if ($Global:Icinga.Protected.RunAsDaemon -eq $TRUE -Or $Global:Icinga.Protected.JEAContext -eq $TRUE) {
|
||||||
Write-IcingaConsolePlain $OutputMessage;
|
throw $OutputMessage;
|
||||||
exit $IcingaEnums.IcingaExitCode.Critical;
|
|
||||||
|
# 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-IcingaInternalPluginExitCode -ExitCode $IcingaEnums.IcingaExitCode.Unknown;
|
||||||
Set-IcingaInternalPluginException -PluginException $OutputMessage;
|
Set-IcingaInternalPluginException -PluginException $OutputMessage;
|
||||||
|
|
||||||
if ($Global:Icinga.Protected.RunAsDaemon -eq $FALSE -And $Global:Icinga.Protected.JEAContext -eq $FALSE) {
|
if ($Global:Icinga.Protected.RunAsDaemon -eq $TRUE -Or $Global:Icinga.Protected.JEAContext -eq $TRUE) {
|
||||||
Write-IcingaConsolePlain $OutputMessage;
|
|
||||||
exit $IcingaEnums.IcingaExitCode.Unknown;
|
|
||||||
} else {
|
|
||||||
throw $OutputMessage;
|
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