mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-23 08:10:16 -05:00
Adds attempt to provide proper error handling for WMI exceptions
Implements #80
This commit is contained in:
parent
27312d3152
commit
2d7cb5ea34
1 changed files with 4 additions and 4 deletions
|
|
@ -49,13 +49,13 @@ function Get-IcingaWindowsInformation()
|
|||
$ErrorMessage = $_.Exception.Message;
|
||||
$ErrorCode = ($_.Exception.HResult -band 0xFFFF);
|
||||
|
||||
switch ($ErrorCode) {
|
||||
switch ($ErrorName) {
|
||||
# Permission error
|
||||
5376 {
|
||||
'InvalidOperation' {
|
||||
Exit-IcingaThrowException -ExceptionType 'Permission' -ExceptionThrown $IcingaExceptions.Permission.WMIObject -CustomMessage $ClassName -Force;
|
||||
};
|
||||
# Invalid Class
|
||||
5377 {
|
||||
'InvalidType' {
|
||||
Exit-IcingaThrowException -ExceptionType 'Input' -ExceptionThrown $IcingaExceptions.Inputs.WmiObjectClassUnknown -CustomMessage $ClassName -Force;
|
||||
};
|
||||
# All other errors
|
||||
|
|
|
|||
Loading…
Reference in a new issue