mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-20 23:00:35 -05:00
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:
commit
d7a1745e39
2 changed files with 11 additions and 4 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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';
|
||||
|
|
|
|||
Loading…
Reference in a new issue