From a878c6a4004f24acfb000a8734440033f74d0107 Mon Sep 17 00:00:00 2001 From: Niko Ehrenfeuchter <nikolaus.ehrenfeuchter@unibas.ch> Date: Tue, 6 Mar 2018 13:53:02 +0100 Subject: [PATCH] Be more conservative in Exit-IfDirMissing. An exception would otherwise result in a silenced error as the output would be discarded. --- Updater/Update-Service.ps1 | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Updater/Update-Service.ps1 b/Updater/Update-Service.ps1 index 26c4c2a..85e3262 100644 --- a/Updater/Update-Service.ps1 +++ b/Updater/Update-Service.ps1 @@ -87,11 +87,20 @@ function Create-TrayAppStartupShortcut() { function Exit-IfDirMissing([string]$DirName, [string]$Desc) { - if (Test-Path -PathType Container $DirName) { - Write-Verbose "Verified $($Desc) path: [$($DirName)]" - Return + try { + if (Test-Path -PathType Container $DirName) { + Write-Verbose "Verified $($Desc) path: [$($DirName)]" + Return + } + } + catch { + $exmsg = $($_.Exception.Message) + } + $msg = "Failed checking $($Desc) path [$($DirName)]" + if ($exmsg.Length -gt 0){ + $msg += ":`n$($exmsg)" } - $msg = "ERROR: can't find / access $($Desc) path: [$($DirName)]" + Log-Error $msg Send-MailReport -Subject "path or permission error" -Body $msg Exit } -- GitLab