Skip to content

Rename error cause fields to source - #572

Open
mohammadp1001 wants to merge 1 commit into
eclipse-opendut:mainfrom
mohammadp1001:552-rename-cause-to-source
Open

Rename error cause fields to source#572
mohammadp1001 wants to merge 1 commit into
eclipse-opendut:mainfrom
mohammadp1001:552-rename-cause-to-source

Conversation

@mohammadp1001

@mohammadp1001 mohammadp1001 commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Closes #552

thiserror automatically treats a field named source as 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

  • Error type fields named cause renamed to source, and the now-redundant #[source] annotations removed.
  • The corresponding .map_err() bindings, closure parameters and local variables renamed to match.

Two cases that could not simply become source

A plain find & replace does not work everywhere:

  1. String-typed causes. A cause field holding a String is not an error, so thiserror rejects it as a source. Those fields are renamed to message instead. Where a message field already existed on the same variant (OpentelemetryConfigError::ClientAuthentication), the new field is called details.
  2. Name collisions. Where an unrelated source was already in scope - notably the VIPER source: &Source constructor parameters, where source means a source file - the error value is named error to avoid the collision.

`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
@mohammadp1001

Copy link
Copy Markdown
Contributor Author

I need to check why ci pipeline is failing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rename cause to source error handling

1 participant