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/http_util.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/http_util.rs')
-rw-r--r-- | cli/http_util.rs | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/cli/http_util.rs b/cli/http_util.rs index c24792a7f..724c00b76 100644 --- a/cli/http_util.rs +++ b/cli/http_util.rs @@ -1,7 +1,4 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. -use crate::deno_error; -use crate::deno_error::DenoError; -use crate::deno_error::ErrorKind; use crate::version; use bytes::Bytes; use deno_core::ErrBox; @@ -49,8 +46,8 @@ pub fn create_http_client(ca_file: Option<String>) -> Result<Client, ErrBox> { } builder.build().map_err(|_| { - ErrBox::from(DenoError::new( - ErrorKind::Other, + ErrBox::from(io::Error::new( + io::ErrorKind::Other, "Unable to build http client".to_string(), )) }) @@ -145,8 +142,8 @@ pub fn fetch_once( if response.status().is_client_error() || response.status().is_server_error() { - let err = DenoError::new( - deno_error::ErrorKind::Other, + let err = io::Error::new( + io::ErrorKind::Other, format!("Import '{}' failed: {}", &url, response.status()), ); return Err(err.into()); |