Merge pull request #234 from Icinga:feature/allow_custom_exception_list_for_icinga_exceptions

Adds support to allow custom exception lists
This commit is contained in:
Lord Hepipud 2021-04-28 09:45:52 +02:00 committed by GitHub
commit d7a1745e39
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 4 deletions

View file

@ -13,6 +13,8 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
### Enhancements
* [#234](https://github.com/Icinga/icinga-powershell-framework/pull/234) Adds support to allow custom exception lists for Icinga Exceptions, making it easier for different modules to ship their own exception messages
### Bugfixes
## 1.4.1 (2021-03-10)

View file

@ -7,6 +7,7 @@ function Exit-IcingaThrowException()
$ExceptionThrown,
[ValidateSet('Permission', 'Input', 'Configuration', 'Connection', 'Unhandled', 'Custom')]
[string]$ExceptionType = 'Unhandled',
[hashtable]$ExceptionList = @{ },
[string]$KnowledgeBaseId,
[switch]$Force
);
@ -21,25 +22,29 @@ function Exit-IcingaThrowException()
}
}
if ($null -eq $ExceptionList -Or $ExceptionList.Count -eq 0) {
$ExceptionList = $IcingaExceptions;
}
$ExceptionMessageLib = $null;
$ExceptionTypeString = '';
switch ($ExceptionType) {
'Permission' {
$ExceptionTypeString = 'Permission';
$ExceptionMessageLib = $IcingaExceptions.Permission;
$ExceptionMessageLib = $ExceptionList.Permission;
};
'Input' {
$ExceptionTypeString = 'Invalid Input';
$ExceptionMessageLib = $IcingaExceptions.Inputs;
$ExceptionMessageLib = $ExceptionList.Inputs;
};
'Configuration' {
$ExceptionTypeString = 'Invalid Configuration';
$ExceptionMessageLib = $IcingaExceptions.Configuration;
$ExceptionMessageLib = $ExceptionList.Configuration;
};
'Connection' {
$ExceptionTypeString = 'Connection error';
$ExceptionMessageLib = $IcingaExceptions.Connection;
$ExceptionMessageLib = $ExceptionList.Connection;
};
'Unhandled' {
$ExceptionTypeString = 'Unhandled';