pahi icon indicating copy to clipboard operation
pahi copied to clipboard

Runtime errors don't exit non-zero

Open oldaccountdeadname opened this issue 2 years ago • 0 comments

Running Pa'i for part of a checkPhase in Nix, I ran into the following error:

[2021-11-11T05:33:57Z ERROR pahi] runtime error: IO Error: Permission denied (os error 13)

However, Nix completed the check silently, with no indication that anything was wrong as the exit status from Pa'i was 0. This is despite the requested code not actually running, and Pa'i not being able to do the thing it was invoked to do. This potentially misleading exit code is a bug, correct?


For what it's worth, here's the tiny commit I'm using for a violent exit, available for a git am assuming it all looks fine:

From c02c00dea2d43af0c7c1139dc86089a794348645 Mon Sep 17 00:00:00 2001
From: "lincoln auster [they/them]" <[email protected]>
Date: Wed, 10 Nov 2021 22:23:07 -0700
Subject: [PATCH] exit non-zero if a runtime error is encountered

Failing silently is usually not a good thing. If the Wasm child can't
run, for whatever reason, something has gone wrong, and we now return 1.
Why 1? It's not 0.
---
 pahi/src/main.rs | 1 +
 1 file changed, 1 insertion(+)

diff --git a/pahi/src/main.rs b/pahi/src/main.rs
index 9323ced..4a1cfa1 100644
--- a/pahi/src/main.rs
+++ b/pahi/src/main.rs
@@ -75,6 +75,7 @@ fn main() -> Result<()> {
         }
         Err(why) => {
             error!("runtime error: {}", why);
+            std::process::exit(1);
         }
     }
 
-- 
2.33.1

oldaccountdeadname avatar Nov 11 '21 05:11 oldaccountdeadname