diff --git a/lib/icinga/exception/Exit-IcingaThrowException.psm1 b/lib/icinga/exception/Exit-IcingaThrowException.psm1 index 08e7487..0431292 100644 --- a/lib/icinga/exception/Exit-IcingaThrowException.psm1 +++ b/lib/icinga/exception/Exit-IcingaThrowException.psm1 @@ -52,11 +52,6 @@ function Exit-IcingaThrowException() [string]$ExceptionName = ''; [string]$ExceptionIWKB = $KnowledgeBaseId; - if ($ExceptionThrown -is [hashtable]) { - $ExceptionIWKB = $ExceptionThrown.IWKB; - $ExceptionThrown = $ExceptionThrown.Message; - } - if ($null -ne $ExceptionMessageLib) { foreach ($definedError in $ExceptionMessageLib.Keys) { 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) { $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}',