[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 2/3] Throw on build command failure instead of exiting



Exiting is not sufficient to signal the error condition in some cases
(as observed on CI).

Explicitly throw an error instead.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@xxxxxxxxxx>
---
 msbuild.ps1 | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/msbuild.ps1 b/msbuild.ps1
index 58053e2..d9785db 100644
--- a/msbuild.ps1
+++ b/msbuild.ps1
@@ -40,8 +40,7 @@ Function Run-MSBuild {
 
        Invoke-Expression $c
        if ($LASTEXITCODE -ne 0) {
-               Write-Host -ForegroundColor Red "ERROR: MSBuild failed, code:" 
$LASTEXITCODE
-               Exit $LASTEXITCODE
+               throw "ERROR: MSBuild failed, code: $LASTEXITCODE"
        }
 }
 
@@ -117,8 +116,7 @@ Function Run-CodeQL {
        $b += $database
        Invoke-Expression $b
        if ($LASTEXITCODE -ne 0) {
-               Write-Host -ForegroundColor Red "ERROR: CodeQL failed, code:" 
$LASTEXITCODE
-               Exit $LASTEXITCODE
+               throw "ERROR: CodeQL failed, code: $LASTEXITCODE"
        }
        Remove-Item $bat
 
@@ -136,8 +134,7 @@ Function Run-CodeQL {
 
        Invoke-Expression $c
        if ($LASTEXITCODE -ne 0) {
-               Write-Host -ForegroundColor Red "ERROR: CodeQL failed, code:" 
$LASTEXITCODE
-               Exit $LASTEXITCODE
+               throw "ERROR: CodeQL failed, code: $LASTEXITCODE"
        }
 
        Copy-Item $sarif -Destination $SolutionPath
-- 
2.50.0.windows.1



Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.