summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
Diffstat (limited to 'cli')
-rw-r--r--cli/lib.rs5
-rw-r--r--cli/worker.rs8
2 files changed, 13 insertions, 0 deletions
diff --git a/cli/lib.rs b/cli/lib.rs
index df4cbbdf0..b191d5e87 100644
--- a/cli/lib.rs
+++ b/cli/lib.rs
@@ -349,6 +349,11 @@ fn bundle_command(flags: DenoFlags) {
fn run_repl(flags: DenoFlags) {
let (mut worker, _state) = create_worker_and_state(flags);
+ // Make repl continue to function under uncaught async errors.
+ worker.set_error_handler(Box::new(|err| {
+ eprintln!("{}", err.to_string());
+ Ok(())
+ }));
// Setup runtime.
js_check(worker.execute("denoMain()"));
let main_future = async move {
diff --git a/cli/worker.rs b/cli/worker.rs
index 814e7f440..e35458d39 100644
--- a/cli/worker.rs
+++ b/cli/worker.rs
@@ -96,6 +96,14 @@ impl Worker {
}
}
+ pub fn set_error_handler(
+ &mut self,
+ handler: Box<dyn FnMut(ErrBox) -> Result<(), ErrBox>>,
+ ) {
+ let mut i = self.isolate.lock().unwrap();
+ i.set_error_handler(handler);
+ }
+
/// Same as execute2() but the filename defaults to "$CWD/__anonymous__".
pub fn execute(&mut self, js_source: &str) -> Result<(), ErrBox> {
let path = env::current_dir().unwrap().join("__anonymous__");