mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-21 07:10:15 -05:00
Added exception handling on creating cache files
This commit is contained in:
parent
d5e3e78cbe
commit
f5d6f152ce
1 changed files with 6 additions and 1 deletions
5
lib/core/cache/Set-IcingaCacheData.psm1
vendored
5
lib/core/cache/Set-IcingaCacheData.psm1
vendored
|
|
@ -13,7 +13,12 @@ function Set-IcingaCacheData()
|
||||||
if ((Test-Path $CacheFile)) {
|
if ((Test-Path $CacheFile)) {
|
||||||
$cacheData = Get-IcingaCacheData -Space $Space -CacheStore $CacheStore;
|
$cacheData = Get-IcingaCacheData -Space $Space -CacheStore $CacheStore;
|
||||||
} else {
|
} else {
|
||||||
|
try {
|
||||||
New-Item -Path $CacheFile -Force | Out-Null;
|
New-Item -Path $CacheFile -Force | Out-Null;
|
||||||
|
} catch {
|
||||||
|
Exit-IcingaThrowException -InputString $_.Exception -CustomMessage (Get-IcingaCacheDir) -StringPattern 'NewItemUnauthorizedAccessError' -ExceptionType 'Permission' -ExceptionThrown $IcingaExceptions.Permission.CacheFolder;
|
||||||
|
Exit-IcingaThrowException -CustomMessage $_.Exception -ExceptionType 'Unhandled' -Force;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($null -eq $cacheData -or $cacheData.Count -eq 0) {
|
if ($null -eq $cacheData -or $cacheData.Count -eq 0) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue