diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2020-02-23 14:51:29 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-23 14:51:29 -0500 |
commit | 4e1abb4f3a1fbdac25b1e7db0588572e4d5a6579 (patch) | |
tree | 644ace7dc1acac7b09bfab037e0ca589fa11987b /cli/ops/plugins.rs | |
parent | 45eb2f9b37c2c7498c58eb45f76667aaa4a7d731 (diff) |
refactor: use OpError instead of ErrBox for errors in ops (#4058)
To better reflect changes in error types in JS from #3662 this PR changes
default error type used in ops from "ErrBox" to "OpError".
"OpError" is a type that can be sent over to JSON; it has all
information needed to construct error in JavaScript. That
made "GetErrorKind" trait useless and so it was removed altogether.
To provide compatibility with previous use of "ErrBox" an implementation of
"From<ErrBox> for OpError" was added, however, it is an escape hatch and
ops implementors should strive to use "OpError" directly.
Diffstat (limited to 'cli/ops/plugins.rs')
-rw-r--r-- | cli/ops/plugins.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/cli/ops/plugins.rs b/cli/ops/plugins.rs index aa810e0ea..67ad5a13a 100644 --- a/cli/ops/plugins.rs +++ b/cli/ops/plugins.rs @@ -1,5 +1,6 @@ use super::dispatch_json::{Deserialize, JsonOp, Value}; use crate::fs as deno_fs; +use crate::op_error::OpError; use crate::ops::json_op; use crate::state::State; use deno_core::*; @@ -19,10 +20,10 @@ pub fn init(i: &mut Isolate, s: &State, r: Rc<deno_core::OpRegistry>) { ); } -fn open_plugin<P: AsRef<OsStr>>(lib_path: P) -> Result<Library, ErrBox> { +fn open_plugin<P: AsRef<OsStr>>(lib_path: P) -> Result<Library, OpError> { debug!("Loading Plugin: {:#?}", lib_path.as_ref()); - Library::open(lib_path).map_err(ErrBox::from) + Library::open(lib_path).map_err(OpError::from) } struct PluginResource { @@ -55,7 +56,7 @@ pub fn op_open_plugin( state: &State, args: Value, _zero_copy: Option<ZeroCopyBuf>, -) -> Result<JsonOp, ErrBox> { +) -> Result<JsonOp, OpError> { let args: OpenPluginArgs = serde_json::from_value(args)?; let filename = deno_fs::resolve_from_cwd(Path::new(&args.filename))?; |