From 2c04a1ff64af95dea11853be20e8030f05a06dde Mon Sep 17 00:00:00 2001 From: Lord Hepipud Date: Tue, 17 Sep 2019 17:12:06 +0200 Subject: [PATCH] Added ability to force exception throwing --- ...96991491710121821213111390108.lastcheck.json | 3 +++ .../exception/Exit-IcingaThrowException.psm1 | 17 ++++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) create mode 100644 cache/provider/eventlog/1781451901841216379518196991491710121821213111390108.lastcheck.json diff --git a/cache/provider/eventlog/1781451901841216379518196991491710121821213111390108.lastcheck.json b/cache/provider/eventlog/1781451901841216379518196991491710121821213111390108.lastcheck.json new file mode 100644 index 0000000..599898a --- /dev/null +++ b/cache/provider/eventlog/1781451901841216379518196991491710121821213111390108.lastcheck.json @@ -0,0 +1,3 @@ +{ + "1781451901841216379518196991491710121821213111390108.lastcheck": 132132048543175098 +} diff --git a/lib/icinga/exception/Exit-IcingaThrowException.psm1 b/lib/icinga/exception/Exit-IcingaThrowException.psm1 index d4610ee..2e2ae8f 100644 --- a/lib/icinga/exception/Exit-IcingaThrowException.psm1 +++ b/lib/icinga/exception/Exit-IcingaThrowException.psm1 @@ -6,15 +6,18 @@ function Exit-IcingaThrowException() [string]$CustomMessage, [string]$ExceptionThrown, [ValidateSet('Permission','Input','Unhandled')] - [string]$ExceptionType = 'Unhandled' + [string]$ExceptionType = 'Unhandled', + [switch]$Force ); - if ($null -eq $InputString -Or [string]::IsNullOrEmpty($InputString)) { - return; - } + if ($Force -eq $FALSE) { + if ($null -eq $InputString -Or [string]::IsNullOrEmpty($InputString)) { + return; + } - if (-Not $InputString.Contains($StringPattern)) { - return; + if (-Not $InputString.Contains($StringPattern)) { + return; + } } $ExceptionMessageLib = $null; @@ -44,7 +47,7 @@ function Exit-IcingaThrowException() } } } else { - $ExceptionName = 'Unhandled Exception'; + $ExceptionName = 'Unhandled Exception'; $ExceptionThrown = [string]::Format( 'Unhandled exception occured:{0}{1}', "`r`n",