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.
This commit is contained in:
Bartek Iwańczuk 2020-02-23 14:51:29 -05:00 committed by GitHub
parent 45eb2f9b37
commit 4e1abb4f3a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
38 changed files with 794 additions and 836 deletions

View file

@ -1,5 +1,5 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
use deno_core::ErrBox;
use crate::op_error::OpError;
use std::future::Future;
use std::net::SocketAddr;
use std::net::ToSocketAddrs;
@ -21,7 +21,7 @@ pub struct ResolveAddrFuture {
}
impl Future for ResolveAddrFuture {
type Output = Result<SocketAddr, ErrBox>;
type Output = Result<SocketAddr, OpError>;
fn poll(self: Pin<&mut Self>, _cx: &mut Context) -> Poll<Self::Output> {
let inner = self.get_mut();
@ -45,7 +45,7 @@ impl Future for ResolveAddrFuture {
addr
};
let addr_port_pair = (addr, inner.port);
let r = addr_port_pair.to_socket_addrs().map_err(ErrBox::from);
let r = addr_port_pair.to_socket_addrs().map_err(OpError::from);
Poll::Ready(r.and_then(|mut iter| match iter.next() {
Some(a) => Ok(a),