Added ability to force exception throwing

This commit is contained in:
Lord Hepipud 2019-09-17 17:12:06 +02:00
parent 17d8308e1f
commit 2c04a1ff64
2 changed files with 13 additions and 7 deletions

View file

@ -0,0 +1,3 @@
{
"1781451901841216379518196991491710121821213111390108.lastcheck": 132132048543175098
}

View file

@ -6,15 +6,18 @@ function Exit-IcingaThrowException()
[string]$CustomMessage, [string]$CustomMessage,
[string]$ExceptionThrown, [string]$ExceptionThrown,
[ValidateSet('Permission','Input','Unhandled')] [ValidateSet('Permission','Input','Unhandled')]
[string]$ExceptionType = 'Unhandled' [string]$ExceptionType = 'Unhandled',
[switch]$Force
); );
if ($null -eq $InputString -Or [string]::IsNullOrEmpty($InputString)) { if ($Force -eq $FALSE) {
return; if ($null -eq $InputString -Or [string]::IsNullOrEmpty($InputString)) {
} return;
}
if (-Not $InputString.Contains($StringPattern)) { if (-Not $InputString.Contains($StringPattern)) {
return; return;
}
} }
$ExceptionMessageLib = $null; $ExceptionMessageLib = $null;
@ -44,7 +47,7 @@ function Exit-IcingaThrowException()
} }
} }
} else { } else {
$ExceptionName = 'Unhandled Exception'; $ExceptionName = 'Unhandled Exception';
$ExceptionThrown = [string]::Format( $ExceptionThrown = [string]::Format(
'Unhandled exception occured:{0}{1}', 'Unhandled exception occured:{0}{1}',
"`r`n", "`r`n",