From 49ebde68356215b3ab33d1ed082af6036e10bbbb Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Fri, 21 Nov 2025 17:57:18 +0900 Subject: [PATCH] Improve error handling in afterInstall.ps1 Enhanced error reporting by checking if caught errors are System.Exception and printing the appropriate message. This provides clearer output for both exception and non-exception error types during file download, extraction, and main script execution. --- afterInstall.ps1 | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/afterInstall.ps1 b/afterInstall.ps1 index 5cedc66..5b2e23b 100644 --- a/afterInstall.ps1 +++ b/afterInstall.ps1 @@ -69,7 +69,11 @@ function Download-File { } catch { Write-Host "[ERROR] Failed to download: $Url" - Write-Host $_.Exception.Message + if ($_ -is [System.Exception]) { + Write-Host $_.Exception.Message + } else { + Write-Host $_ + } throw } } @@ -101,7 +105,11 @@ function Extract-CompressedFile { } catch { Write-Host "[ERROR] Failed to extract: $CompressedPath" - Write-Host $_.Exception.Message + if ($_ -is [System.Exception]) { + Write-Host $_.Exception.Message + } else { + Write-Host $_ + } throw } @@ -170,7 +178,11 @@ function Extract-TarGzArchive { } catch { Write-Host "[ERROR] Failed to extract TAR.GZ archive: $ArchivePath" - Write-Host $_.Exception.Message + if ($_ -is [System.Exception]) { + Write-Host $_.Exception.Message + } else { + Write-Host $_ + } throw } } @@ -319,8 +331,12 @@ try { } } catch { - Write-Host "[FATAL] Download phase faled." - Write-Host $_.Exception.Message + Write-Host "[FATAL] Download phase failed." + if ($_ -is [System.Exception]) { + Write-Host $_.Exception.Message + } else { + Write-Host $_ + } exit 1 }