From 3d2d0ee771abe308aee9a0ab6c89fd09bac80330 Mon Sep 17 00:00:00 2001 From: Kitson Kelly Date: Thu, 26 Sep 2019 00:46:58 +1000 Subject: Handle uncaught worker errors without panicking (#3019) --- cli/deno_error.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'cli/deno_error.rs') 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 } -- cgit v1.2.3