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.
This commit is contained in:
Namhyeon Go 2025-11-21 17:57:18 +09:00
parent 9b6fa4d233
commit 49ebde6835

View File

@ -69,7 +69,11 @@ function Download-File {
}
catch {
Write-Host "[ERROR] Failed to download: $Url"
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"
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"
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 "[FATAL] Download phase failed."
if ($_ -is [System.Exception]) {
Write-Host $_.Exception.Message
} else {
Write-Host $_
}
exit 1
}