Added exception handling on creating cache files

This commit is contained in:
Lord Hepipud 2019-09-19 12:26:48 +02:00
parent d5e3e78cbe
commit f5d6f152ce

View file

@ -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) {