Rename error cause fields to source - #572
Open
mohammadp1001 wants to merge 1 commit into
Open
Conversation
`thiserror` automatically treats a field named `source` as the source error, so the explicit `#[source]` annotation is no longer needed on these fields. Renames the fields in the error types along with the corresponding `.map_err()` bindings, closure parameters and locals. Two cases cannot simply become `source`: * A `cause` field holding a `String` is not an error, so `thiserror` rejects it as a source. Those fields are renamed to `message` instead (or `details`, where a `message` field already existed). * Where an unrelated `source` binding was already in scope, such as the VIPER `source: &Source` constructor parameters, the error value is named `error` to avoid the collision. The `cause` fields of the protobuf messages are left untouched, since renaming them would change the wire API rather than the error types. Closes eclipse-opendut#552
Contributor
Author
|
I need to check why ci pipeline is failing. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #552
thiserrorautomatically treats a field namedsourceas the source error, so the explicit#[source]annotation is no longer needed. This renames the fields across the codebase to establish that convention.What changed
causerenamed tosource, and the now-redundant#[source]annotations removed..map_err()bindings, closure parameters and local variables renamed to match.Two cases that could not simply become
sourceA plain find & replace does not work everywhere:
String-typed causes. Acausefield holding aStringis not an error, sothiserrorrejects it as a source. Those fields are renamed tomessageinstead. Where amessagefield already existed on the same variant (OpentelemetryConfigError::ClientAuthentication), the new field is calleddetails.sourcewas already in scope - notably the VIPERsource: &Sourceconstructor parameters, wheresourcemeans a source file - the error value is namederrorto avoid the collision.