summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorkyren <kerriganw@gmail.com>2017-10-26 16:49:16 -0400
committerkyren <kerriganw@gmail.com>2017-10-26 16:49:16 -0400
commit892069edd64c73e06c23ea24b77a4457124a38fb (patch)
tree1861933626f9f1f23b4dd6a5b77086c644c13e37 /src
parent8592af1b1643f0a83c8c09c32c925236c6d8b47a (diff)
downloadmlua-892069edd64c73e06c23ea24b77a4457124a38fb.zip
Correctly wrap external errors so that Debug trait and Error::cause are correct
Diffstat (limited to 'src')
-rw-r--r--src/error.rs13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/error.rs b/src/error.rs
index 7206df3..04e909a 100644
--- a/src/error.rs
+++ b/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()))