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
|
### 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
|
### Bugfixes
|
||||||
|
|
||||||
## 1.4.1 (2021-03-10)
|
## 1.4.1 (2021-03-10)
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ function Exit-IcingaThrowException()
|
||||||
$ExceptionThrown,
|
$ExceptionThrown,
|
||||||
[ValidateSet('Permission', 'Input', 'Configuration', 'Connection', 'Unhandled', 'Custom')]
|
[ValidateSet('Permission', 'Input', 'Configuration', 'Connection', 'Unhandled', 'Custom')]
|
||||||
[string]$ExceptionType = 'Unhandled',
|
[string]$ExceptionType = 'Unhandled',
|
||||||
|
[hashtable]$ExceptionList = @{ },
|
||||||
[string]$KnowledgeBaseId,
|
[string]$KnowledgeBaseId,
|
||||||
[switch]$Force
|
[switch]$Force
|
||||||
);
|
);
|
||||||
|
|
@ -21,25 +22,29 @@ function Exit-IcingaThrowException()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($null -eq $ExceptionList -Or $ExceptionList.Count -eq 0) {
|
||||||
|
$ExceptionList = $IcingaExceptions;
|
||||||
|
}
|
||||||
|
|
||||||
$ExceptionMessageLib = $null;
|
$ExceptionMessageLib = $null;
|
||||||
$ExceptionTypeString = '';
|
$ExceptionTypeString = '';
|
||||||
|
|
||||||
switch ($ExceptionType) {
|
switch ($ExceptionType) {
|
||||||
'Permission' {
|
'Permission' {
|
||||||
$ExceptionTypeString = 'Permission';
|
$ExceptionTypeString = 'Permission';
|
||||||
$ExceptionMessageLib = $IcingaExceptions.Permission;
|
$ExceptionMessageLib = $ExceptionList.Permission;
|
||||||
};
|
};
|
||||||
'Input' {
|
'Input' {
|
||||||
$ExceptionTypeString = 'Invalid Input';
|
$ExceptionTypeString = 'Invalid Input';
|
||||||
$ExceptionMessageLib = $IcingaExceptions.Inputs;
|
$ExceptionMessageLib = $ExceptionList.Inputs;
|
||||||
};
|
};
|
||||||
'Configuration' {
|
'Configuration' {
|
||||||
$ExceptionTypeString = 'Invalid Configuration';
|
$ExceptionTypeString = 'Invalid Configuration';
|
||||||
$ExceptionMessageLib = $IcingaExceptions.Configuration;
|
$ExceptionMessageLib = $ExceptionList.Configuration;
|
||||||
};
|
};
|
||||||
'Connection' {
|
'Connection' {
|
||||||
$ExceptionTypeString = 'Connection error';
|
$ExceptionTypeString = 'Connection error';
|
||||||
$ExceptionMessageLib = $IcingaExceptions.Connection;
|
$ExceptionMessageLib = $ExceptionList.Connection;
|
||||||
};
|
};
|
||||||
'Unhandled' {
|
'Unhandled' {
|
||||||
$ExceptionTypeString = 'Unhandled';
|
$ExceptionTypeString = 'Unhandled';
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue