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.
This commit is contained in:
kyren 2017-09-26 11:36:50 -04:00
parent ef538d8757
commit cc502379c1
1 changed files with 4 additions and 2 deletions

View File

@ -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(),
}
}