Skip to content

Error inconsistency: Some errors both have source and include source in display #11667

Open

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:

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:

#[error("invalid glTF file: {0}")]
Gltf(#[from] gltf::Error),

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.

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

Metadata

Assignees

No one assigned

    Labels

    A-DiagnosticsLogging, crash handling, error reporting and performance analysisC-Code-QualityA section of code that is hard to understand or change

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions