From 6d3919ee7388b19f13e76ed32933cf0d29207815 Mon Sep 17 00:00:00 2001
From: Niko Ehrenfeuchter <nikolaus.ehrenfeuchter@unibas.ch>
Date: Fri, 8 Dec 2017 16:50:24 +0100
Subject: [PATCH] Wrap creation of marker file in try/catch block.

Refers to #13
---
 AutoTx-Updater/Update-Service.ps1 | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/AutoTx-Updater/Update-Service.ps1 b/AutoTx-Updater/Update-Service.ps1
index 0b0f5b6..07b4bc8 100644
--- a/AutoTx-Updater/Update-Service.ps1
+++ b/AutoTx-Updater/Update-Service.ps1
@@ -232,7 +232,14 @@ function Update-ServiceBinaries {
     Log-Info "Marker file ($($MarkerFile)) missing, trying to update service."
     Stop-MyService
     Copy-ServiceFiles
-    New-Item -Type File "$MarkerFile" | Out-Null
+    try {
+        New-Item -Type File "$MarkerFile" -ErrorAction Stop | Out-Null
+        Write-Verbose "Created marker file: $($MarkerFile)"
+    }
+    catch {
+        Log-Error "Creating $($MarkerFile) FAILED!`n$($_.Exception.Message)"
+        Exit
+    }
 }
 
 
-- 
GitLab