Fixes exception output not properly constructed

This commit is contained in:
Lord Hepipud 2020-11-27 16:52:24 +01:00
parent 5530a84acd
commit 478d8f3566

View file

@ -52,11 +52,6 @@ function Exit-IcingaThrowException()
[string]$ExceptionName = ''; [string]$ExceptionName = '';
[string]$ExceptionIWKB = $KnowledgeBaseId; [string]$ExceptionIWKB = $KnowledgeBaseId;
if ($ExceptionThrown -is [hashtable]) {
$ExceptionIWKB = $ExceptionThrown.IWKB;
$ExceptionThrown = $ExceptionThrown.Message;
}
if ($null -ne $ExceptionMessageLib) { if ($null -ne $ExceptionMessageLib) {
foreach ($definedError in $ExceptionMessageLib.Keys) { foreach ($definedError in $ExceptionMessageLib.Keys) {
if ($ExceptionMessageLib.$definedError -eq $ExceptionThrown) { if ($ExceptionMessageLib.$definedError -eq $ExceptionThrown) {
@ -74,6 +69,11 @@ function Exit-IcingaThrowException()
); );
} }
if ($ExceptionThrown -is [hashtable]) {
$ExceptionIWKB = $ExceptionThrown.IWKB;
$ExceptionThrown = $ExceptionThrown.Message;
}
if ([string]::IsNullOrEmpty($ExceptionIWKB) -eq $FALSE) { if ([string]::IsNullOrEmpty($ExceptionIWKB) -eq $FALSE) {
$ExceptionIWKB = [string]::Format( $ExceptionIWKB = [string]::Format(
'{0}{0}Further details can be found on the Icinga for Windows Knowledge base: https://icinga.com/docs/windows/latest/doc/knowledgebase/{1}', '{0}{0}Further details can be found on the Icinga for Windows Knowledge base: https://icinga.com/docs/windows/latest/doc/knowledgebase/{1}',