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

Upper or lower case error messages? #209

Open
matklad opened this issue Dec 6, 2021 · 1 comment
Open

Upper or lower case error messages? #209

matklad opened this issue Dec 6, 2021 · 1 comment

Comments

@matklad
Copy link

matklad commented Dec 6, 2021

I've noticed that all examples at https://docs.rs/anyhow/latest/anyhow/ use upper case error messages. This feels a bit odd, as I think the stdlib practice is to use lowercase error messages. There's also inconsistency with thiserror examples:

// anyhow repo: 

#[derive(Error, Debug)]
pub enum FormatError {
    #[error("Invalid header (expected {expected:?}, got {found:?})")]
    InvalidHeader {
        expected: String,
        found: String,
    },
    #[error("Missing attribute: {0}")]
    MissingAttribute(String),
}

// thiserror repo:
#[derive(Error, Debug)]
pub enum DataStoreError {
    #[error("data store disconnected")]
    Disconnect(#[from] io::Error),
    #[error("the data for key `{0}` is not available")]
    Redaction(String),
    #[error("invalid header (expected {expected:?}, found {found:?})")]
    InvalidHeader {
        expected: String,
        found: String,
    },
    #[error("unknown data store error")]
    Unknown,
}

Would it be a good idea to send a PR changing anyhow examples to lowercase?

@piegamesde
Copy link

From https://doc.rust-lang.org/stable/std/error/trait.Error.html: "Error messages are typically concise lowercase sentences without trailing punctuation"

I think all libraries should follow that convention for consistency.

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

No branches or pull requests

2 participants