Skip to main content

exit_code_after_failure

Function exit_code_after_failure 

Source
pub fn exit_code_after_failure() -> i32
Expand description

Run the exit event for a program that died on an uncaught exception, and report the status to leave with.

Node fires exit on this path too, and an uncaught exception FORCES the code to 1 — overriding any process.exitCode the script had already set — while a code the handler itself assigns still wins. Verified on node v26.7.0: process.exitCode = 3; process.on('exit', c => console.log(c)); throw new Error('z') prints 1 and exits 1, and process.on('exit', () => { process.exitCode = 9 }); throw new Error('z') exits 9.