diff options
author | Kitson Kelly <me@kitsonkelly.com> | 2019-09-26 00:46:58 +1000 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2019-09-25 10:46:58 -0400 |
commit | 3d2d0ee771abe308aee9a0ab6c89fd09bac80330 (patch) | |
tree | 5cc74b1e38b824d083306c5264a484d64ee6d248 /cli/deno_error.rs | |
parent | 112ce0df1f9e36a57b520aa59dc1767ba0716bb0 (diff) |
Handle uncaught worker errors without panicking (#3019)
Diffstat (limited to 'cli/deno_error.rs')
-rw-r--r-- | cli/deno_error.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/cli/deno_error.rs b/cli/deno_error.rs index 2066d9c52..eb885adb8 100644 --- a/cli/deno_error.rs +++ b/cli/deno_error.rs @@ -22,6 +22,17 @@ pub struct DenoError { msg: String, } +pub fn print_err_and_exit(err: ErrBox) { + eprintln!("{}", err.to_string()); + std::process::exit(1); +} + +pub fn js_check(r: Result<(), ErrBox>) { + if let Err(err) = r { + print_err_and_exit(err); + } +} + impl DenoError { pub fn new(kind: ErrorKind, msg: String) -> Self { Self { kind, msg } |