From ba46a36eb1c7723215bccb97a444735b319f955b Mon Sep 17 00:00:00 2001 From: tigattack <10629864+tigattack@users.noreply.github.com> Date: Thu, 22 May 2025 00:05:44 +0100 Subject: [PATCH 1/2] fix(logger): catch terminating errors from `Stop-Transcript` --- resources/Logger.psm1 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/resources/Logger.psm1 b/resources/Logger.psm1 index 76d7116..a50f12b 100644 --- a/resources/Logger.psm1 +++ b/resources/Logger.psm1 @@ -87,7 +87,12 @@ function Stop-Logging { param() if ($PSCmdlet.ShouldProcess('log file', 'Stop-Transcript')) { Write-LogMessage -Tag 'INFO' -Message 'Stopping transcript logging.' - Stop-Transcript + try { + Stop-Transcript + } + catch { + Write-LogMessage -Tag 'ERROR' -Message 'Failed to stop transcript logging.' + } } } From 62959e3469f0746b2524cc01e126e1dde826e138 Mon Sep 17 00:00:00 2001 From: tigattack <10629864+tigattack@users.noreply.github.com> Date: Thu, 22 May 2025 00:07:01 +0100 Subject: [PATCH 2/2] fix(bootstrap): correctly catch exception when renaming log file --- Bootstrap.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Bootstrap.ps1 b/Bootstrap.ps1 index 3d4b3d1..b1a96d1 100644 --- a/Bootstrap.ps1 +++ b/Bootstrap.ps1 @@ -119,7 +119,7 @@ if ($config.logging.enabled) { # Rename log file to include the job name. try { - Rename-Item -Path $logFile -NewName "$(Split-Path $newLogfile -Leaf)" + Rename-Item -Path $logFile -NewName "$(Split-Path $newLogfile -Leaf)" -ErrorAction Stop } catch { Write-Output "ERROR: Failed to rename log file: $_" | Out-File $logFile -Append