diff options
author | Bert Belder <bertbelder@gmail.com> | 2019-07-11 00:53:48 +0200 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2019-07-11 14:37:00 -0400 |
commit | abe8a113ad8004f160eac5f3f115cb28c5072ba7 (patch) | |
tree | 099b2b019bd7b5d1689cfa5b4bef3ceded10c59d /cli/repl.rs | |
parent | db5c66a638d399d5ebb2832bb7b52e8f76ced49d (diff) |
Refactor error to use dynamic dispatch and traits
This is in preperation for dynamic import (#1789), which is more easily
implemented when errors are dynamic.
Diffstat (limited to 'cli/repl.rs')
-rw-r--r-- | cli/repl.rs | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/cli/repl.rs b/cli/repl.rs index e0d029439..a253e4435 100644 --- a/cli/repl.rs +++ b/cli/repl.rs @@ -1,12 +1,7 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -use rustyline; - -use crate::msg::ErrorKind; -use std::error::Error; - use crate::deno_dir::DenoDir; -use crate::deno_error::new as deno_error; -use crate::deno_error::DenoResult; +use deno::ErrBox; +use rustyline; use std::path::PathBuf; #[cfg(not(windows))] @@ -78,25 +73,25 @@ impl Repl { .unwrap_or(()) } - fn save_history(&mut self) -> DenoResult<()> { + fn save_history(&mut self) -> Result<(), ErrBox> { self .editor .save_history(&self.history_file.to_str().unwrap()) .map(|_| debug!("Saved REPL history to: {:?}", self.history_file)) .map_err(|e| { eprintln!("Unable to save REPL history: {:?} {}", self.history_file, e); - deno_error(ErrorKind::Other, e.description().to_string()) + ErrBox::from(e) }) } - pub fn readline(&mut self, prompt: &str) -> DenoResult<String> { + pub fn readline(&mut self, prompt: &str) -> Result<String, ErrBox> { self .editor .readline(&prompt) .map(|line| { self.editor.add_history_entry(line.clone()); line - }).map_err(|e| deno_error(ErrorKind::Other, e.description().to_string())) + }).map_err(ErrBox::from) // Forward error to TS side for processing } } |