rustonaut / vec1

Rust `Vec<T>` wrapper that gurantees to contain at least 1 element
Apache License 2.0
90 stars 15 forks source link

Consider rewording the error message #35

Open schneiderfelipe opened 4 months ago

schneiderfelipe commented 4 months ago

TL;DR: an error message starting with a lowercase letter and lacking a period at the end might "compose" better.


Currently, the error message reads

https://github.com/rustonaut/vec1/blob/bc8e2cee1e89fbfe5af68e20abb5dac09570c5e4/src/lib.rs#L156

which begins with an uppercase letter and ends with a period.

This makes the following pattern "weird" (this is a synthetic example, but you get the idea)

use std::io;

use thiserror::Error;
use vec1;

#[derive(Error, Debug)]
pub enum SpamError {
    #[error("could not produce spam: {0}")]
    Size0(#[from] vec1::Size0Error),
    #[error("could not read or write spam: {0}")]
    Io(#[from] io::Error),
    // ...
}

In fact, this already happens with serde in some way (e.g., "Cannot produce a Vec1 with a length of zero. at line 1 column 2"; notice the period in the middle of the error message).

So, could the error message read "cannot produce a Vec1 with a length of zero" instead of "Cannot produce a Vec1 with a length of zero."?