Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept top level #[error(...)] attribute on enums to apply to all variants #18

Closed
dtolnay opened this issue Oct 11, 2019 · 1 comment · Fixed by #24
Closed

Accept top level #[error(...)] attribute on enums to apply to all variants #18

dtolnay opened this issue Oct 11, 2019 · 1 comment · Fixed by #24

Comments

@dtolnay
Copy link
Owner

dtolnay commented Oct 11, 2019

use thiserror::Error;

#[derive(Error, Debug)]
#[error("{0}")]
pub enum Error {
    Io(io::Error),
    Json(serde_json::Error),
    Regex(regex::Error),
}

^ this should be treated as equivalent to:

#[derive(Error, Debug)]
pub enum Error {
    #[error("{0}")]
    Io(io::Error),
    #[error("{0}")]
    Json(serde_json::Error),
    #[error("{0}")]
    Regex(regex::Error),
}
@MOZGIII
Copy link

MOZGIII commented Oct 12, 2019

This works, but what if I want to customize one of the variants?

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 a pull request may close this issue.

2 participants