Error inconsistency: Some errors both have source and include source in display
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 171
Description
## What problem does this solve or what need does it fill?
Currently, some errors both have source and include source in display. This is generally [discouraged](https://blog.rust-lang.org/inside-rust/2021/07/01/What-the-error-handling-project-group-is-working-towards.html#guidelines-for-implementing-displayfmt-and-errorsource):
> An error type with a source error should either return that error via source or include that source's error message in its own Display output, but never both.
Example:
https://github.com/bevyengine/bevy/blob/d6f16496461645dac05106a24a44d9f8026225ad/crates/bevy_gltf/src/loader.rs#L60-L61
## What solution would you like?
Remove either `#[from]` or usage in the Display output for all errors.
However, for errors that retain `#[from]`, this means that an output via Display may no longer contain important context. To solve this, all errors should be output via somethink like the currently (unstable) [`Report`](https://doc.rust-lang.org/std/error/struct.Report.html) from std. This will print the error and its sources.
## What alternative(s) have you considered?
Keep everything as it is. This is not strictly needed and will most likely require some extra complexity, e.g.`Report`.
## Additional context
I discovered this when I created a custom error for an `AssetLoader`. I did not include my source error in the Display implementation and when the loader failed, the source error did not show up as it only used the Display implementation.
Contributor guide
Research direction
The issue points to crates/bevy_gltf/src/loader.rs lines 60-61 and the AssetLoader error path; begin by inspecting that example and the linked Rust error-handling guidance. Inventory the affected errors and confirm the intended Display/source policy with maintainers; done requires consistent error behavior and a validated way to show source errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- game-dev
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100