Merge pull request #174 from Icinga:fix/icinga_exception_output

Fix: Fixes exception output not properly constructed
This commit is contained in:
Lord Hepipud 2020-11-27 16:54:07 +01:00 committed by GitHub
commit 967289b1ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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}',