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:
parent
ef538d8757
commit
cc502379c1
|
@ -129,7 +129,9 @@ impl fmt::Display for Error {
|
||||||
Error::UserDataTypeMismatch => write!(fmt, "userdata is not expected type"),
|
Error::UserDataTypeMismatch => write!(fmt, "userdata is not expected type"),
|
||||||
Error::UserDataBorrowError => write!(fmt, "userdata already mutably borrowed"),
|
Error::UserDataBorrowError => write!(fmt, "userdata already mutably borrowed"),
|
||||||
Error::UserDataBorrowMutError => write!(fmt, "userdata already 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),
|
Error::ExternalError(ref err) => err.fmt(fmt),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -146,7 +148,7 @@ impl StdError for Error {
|
||||||
Error::UserDataTypeMismatch => "userdata type mismatch",
|
Error::UserDataTypeMismatch => "userdata type mismatch",
|
||||||
Error::UserDataBorrowError => "userdata already mutably borrowed",
|
Error::UserDataBorrowError => "userdata already mutably borrowed",
|
||||||
Error::UserDataBorrowMutError => "userdata already borrowed",
|
Error::UserDataBorrowMutError => "userdata already borrowed",
|
||||||
Error::CallbackError { ref cause, .. } => cause.description(),
|
Error::CallbackError { .. } => "callback error",
|
||||||
Error::ExternalError(ref err) => err.description(),
|
Error::ExternalError(ref err) => err.description(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue