mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-20 23:00:35 -05:00
Added exception handling on creating cache files
This commit is contained in:
parent
18e6c65744
commit
d3d1a9d238
1 changed files with 6 additions and 1 deletions
7
lib/core/cache/Set-IcingaCacheData.psm1
vendored
7
lib/core/cache/Set-IcingaCacheData.psm1
vendored
|
|
@ -13,7 +13,12 @@ function Set-IcingaCacheData()
|
|||
if ((Test-Path $CacheFile)) {
|
||||
$cacheData = Get-IcingaCacheData -Space $Space -CacheStore $CacheStore;
|
||||
} else {
|
||||
New-Item -Path $CacheFile -Force | Out-Null;
|
||||
try {
|
||||
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) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue