diff options
author | kyren <kerriganw@gmail.com> | 2017-09-26 11:36:50 -0400 |
---|---|---|
committer | kyren <kerriganw@gmail.com> | 2017-09-26 11:36:50 -0400 |
commit | cc502379c1691bd8410b655275b7da4ef05d33a7 (patch) | |
tree | b8a469d2bd49fc8e06bf91ca56c80ea1e9293778 /src/error.rs | |
parent | ef538d8757c345eded11d625be2a69d3b84da093 (diff) | |
download | mlua-cc502379c1691bd8410b655275b7da4ef05d33a7.zip |
Print CallbackError in a better way
CallbackError now, instead of displaying the cause description, instead prints
"callback error: <traceback>". Since the cause is already in the cause chain of
the error, this avoids repeatedly printing the cause of callback errors along
the chain, and also actually prints the callback when using Display on each
error in the chain.
Diffstat (limited to 'src/error.rs')
-rw-r--r-- | src/error.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/error.rs b/src/error.rs index 147f36c..7206df3 100644 --- a/src/error.rs +++ b/src/error.rs @@ -129,7 +129,9 @@ impl fmt::Display for Error { Error::UserDataTypeMismatch => write!(fmt, "userdata is not expected type"), Error::UserDataBorrowError => write!(fmt, "userdata already mutably borrowed"), Error::UserDataBorrowMutError => write!(fmt, "userdata already borrowed"), - Error::CallbackError { ref cause, .. } => write!(fmt, "{}", cause), + Error::CallbackError { ref traceback, .. } => { + write!(fmt, "callback error: {}", traceback) + } Error::ExternalError(ref err) => err.fmt(fmt), } } @@ -146,7 +148,7 @@ impl StdError for Error { Error::UserDataTypeMismatch => "userdata type mismatch", Error::UserDataBorrowError => "userdata already mutably borrowed", Error::UserDataBorrowMutError => "userdata already borrowed", - Error::CallbackError { ref cause, .. } => cause.description(), + Error::CallbackError { .. } => "callback error", Error::ExternalError(ref err) => err.description(), } } |