Correctly wrap external errors so that Debug trait and Error::cause are correct
This commit is contained in:
parent
8592af1b16
commit
892069edd6
13
src/error.rs
13
src/error.rs
|
@ -177,12 +177,17 @@ where
|
|||
E: Into<Box<StdError + Send + Sync>>,
|
||||
{
|
||||
fn to_lua_err(self) -> Error {
|
||||
#[derive(Debug)]
|
||||
struct WrapError(Box<StdError + Send + Sync>);
|
||||
|
||||
impl fmt::Debug for WrapError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fmt::Debug::fmt(&self.0, f)
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for WrapError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
self.0.fmt(f)
|
||||
fmt::Display::fmt(&self.0, f)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -190,6 +195,10 @@ where
|
|||
fn description(&self) -> &str {
|
||||
self.0.description()
|
||||
}
|
||||
|
||||
fn cause(&self) -> Option<&StdError> {
|
||||
self.0.cause()
|
||||
}
|
||||
}
|
||||
|
||||
Error::external(WrapError(self.into()))
|
||||
|
|
Loading…
Reference in New Issue