thiserror
A crate that writes the Error and Display boilerplate for your error types.
thiserror's #[derive(Error)] implements std::error::Error, Display (from #[error(...)]), and From (from #[from]) for an error type; it adds nothing to the public API.
Examples
#[derive(Debug, thiserror::Error)]onenum ConfigErrorwith#[error("unknown setting {0}")] UnknownKey(String)writes theDisplayandErrorimpls for you.#[error(transparent)] Io(#[from] std::io::Error)also writesFrom<io::Error>, so?converts an I/O error intoConfigError::Io.
See also