Closed
Description
I'm trying to write an Error
implementation which supports a set of "important" error, plus a catch-all for various minor errors caused by low-level subsystems. The code looks something like this:
use std::error::Error;
pub enum DecodingError {
EncodingUnknown,
//...several named errors here...
/// Other errors, the details of which are probably unimportant.
Unexpected(Box<Error+Send>)
}
impl Error for DecodingError {
fn description(&self) -> &str { "decoding error" }
fn detail(&self) -> Option<String> { None }
fn cause(&self) -> Option<&Error> {
match self {
&DecodingError::Unexpected(cause) => Some(&*cause),
_ => None
}
}
}
This yields the following error in cause
:
:14:9: 17:10 error: mismatched types: expected
core::option::Option<&std::error::Error+'static>
, foundcore::option::Option<&std::error::Error+Send>
(expected no bounds, foundSend
)
I should presumably be able to convert a Box<Error+Send>
to an &Error
safely, but I can't figure out a way to do it.
Metadata
Metadata
Assignees
Labels
No labels