Description
openedon Feb 2, 2024
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:
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:
bevy/crates/bevy_gltf/src/loader.rs
Lines 60 to 61 in d6f1649
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
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.