-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
errors: expose pub getters for type-erased errors #1087
Conversation
See the following report for details: cargo semver-checks output
|
Sometimes, user might want to downcast `Arc<dyn Error>` to specific error type. Actually, there is a use case for this in cpp-rust-driver, where we need to define custom `SerializeRow` implementation. It returns a custom error type. We would like to match against it during rust-to-C error conversion - downcasting is thus required.
bf668be
to
f7f78c0
Compare
v2: replaced public getters with custom |
BrokenConnectionError exposed a `get_reason` method, which returned an `Arc<dyn>`. We decided it's better to provide our own implementation of `downcast_ref` for the type-erased error types.
f7f78c0
to
42c4c65
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe not very related: Error impls / deriving seem to be a bit inconsistent:
- SerializationError / DeserializationError has derive(Error) + impl Display
- BrokenConnectionError additionally has
#[error("Connection broken, reason: {0}")]
and no manual Display impl - TypeCheckError has
#[error(transparent)]
and no manual Display impl
I wonder if there is a good reason for those differences.
|
Sorry, one more thing: |
This member is actually used directly in |
0f715b3
to
2a23f06
Compare
Flaky test |
Restarted |
Another time in a row. |
Well, flakiness is one more reason to change this test |
Motivation
Sometimes, user might want to downcast
Arc<dyn Error>
to specific error type.Actually, there is a use case for this in cpp-rust-driver, where we need to define custom
SerializeRow
implementation. It returns a custom error type. We would like to match against it during rust-to-C error conversion - downcasting is thus required.See: scylladb/cpp-rust-driver#187
Pre-review checklist
[ ] I added relevant tests for new features and bug fixes.[ ] I have adjusted the documentation in./docs/source/
.[ ] I added appropriateFixes:
annotations to PR description.