Skip to content

Include Location in snafu::report / Report #501

@bgrieder

Description

@bgrieder

When errors include Locations as in this example, it would be nice to specify the Location property name in the snafu::report proc. macro e.g. #[snafu::report(location(location))], so that the location gets printed with the errors.

#[derive(Debug, Snafu)]
pub enum EngineError {

    #[snafu(display("{message}"))]
    UrlParse {

        message: String,

        source: url::ParseError,

        #[snafu(implicit)]
        location: snafu::Location,
    },
}

would print

Error: Unable to frobnicate the mumbletypeg

Caused by these errors (recent errors listed first):
  1: Could not contact the mumbletypeg API
  2: The URL could not be parsed (/path/to/file.rs:123:45)

Note 1: all Location properties need to be named the same, but that is a reasonable constraint
Not 2: I know backtrace is available, but it is expensive to collect

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestfeedback requestedUser feedback desired on a design decision

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions