diff options
Diffstat (limited to 'runtime/js/30_os.js')
-rw-r--r-- | runtime/js/30_os.js | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/runtime/js/30_os.js b/runtime/js/30_os.js index 866fad287..f3dfda886 100644 --- a/runtime/js/30_os.js +++ b/runtime/js/30_os.js @@ -22,7 +22,8 @@ import { const { Error, FunctionPrototypeBind, - NumberParseInt, + NumberIsInteger, + RangeError, SymbolFor, TypeError, } = primordials; @@ -102,13 +103,17 @@ function getExitCode() { } function setExitCode(value) { - const code = NumberParseInt(value, 10); - if (typeof code !== "number") { + if (typeof value !== "number") { throw new TypeError( - `Exit code must be a number, got: ${code} (${typeof code}).`, + `Exit code must be a number, got: ${value} (${typeof value})`, ); } - op_set_exit_code(code); + if (!NumberIsInteger(value)) { + throw new RangeError( + `Exit code must be an integer, got: ${value}`, + ); + } + op_set_exit_code(value); } function setEnv(key, value) { |