mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-20 23:00:35 -05:00
Added proper exception handling for Cache write failures
This commit is contained in:
parent
f92fc80707
commit
0d7954617c
2 changed files with 7 additions and 1 deletions
7
lib/core/cache/Set-IcingaCacheData.psm1
vendored
7
lib/core/cache/Set-IcingaCacheData.psm1
vendored
|
|
@ -28,5 +28,10 @@ function Set-IcingaCacheData()
|
|||
}
|
||||
}
|
||||
|
||||
Set-Content -Path $CacheFile -Value (ConvertTo-Json -InputObject $cacheData -Depth 100) | Out-Null;
|
||||
try {
|
||||
Set-Content -Path $CacheFile -Value (ConvertTo-Json -InputObject $cacheData -Depth 100) | Out-Null;
|
||||
} catch {
|
||||
Exit-IcingaThrowException -InputString $_.Exception -CustomMessage (Get-IcingaCacheDir) -StringPattern 'System.UnauthorizedAccessException' -ExceptionType 'Permission' -ExceptionThrown $IcingaExceptions.Permission.CacheFolder;
|
||||
Exit-IcingaThrowException -CustomMessage $_.Exception -ExceptionType 'Unhandled' -Force;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
[hashtable]$Permission = @{
|
||||
PerformanceCounter = 'A Plugin failed to fetch Performance Counter information. This may be caused when the used Service User is not permitted to access these information. To fix this, please add the User the Icinga Agent is running on into the "Performance Log Users" group and restart the service.';
|
||||
CacheFolder = "A plugin failed to write new data into the configured cache directory. Please update the permissions of this folder to allow write access for the user the Icinga Service is running with or use another folder as cache directory.";
|
||||
};
|
||||
|
||||
[hashtable]$Inputs = @{
|
||||
|
|
|
|||
Loading…
Reference in a new issue