diff --git a/README.md b/README.md index 7c67cb2..60fbef0 100644 --- a/README.md +++ b/README.md @@ -197,7 +197,9 @@ pub enum DataStoreError { // Private and free to change across minor version of the crate. #[derive(Error, Debug)] enum ErrorRepr { - ... + #[error("invalid input")] + InvalidInput(#[from] InvalidInputError), + // Additional error variants can be added here } ``` diff --git a/src/lib.rs b/src/lib.rs index c26aa0c..fae9b80 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -245,10 +245,22 @@ //! // Private and free to change across minor version of the crate. //! #[derive(Error, Debug)] //! enum ErrorRepr { -//! # /* -//! ... -//! # */ +//! #[error("invalid input")] +//! InvalidInput(#[from] InvalidInputError), //! } +//! # +//! # #[derive(Error, Debug)] +//! # #[error("invalid input")] +//! # struct InvalidInputError; +//! # +//! # fn process() -> Result<(), ErrorRepr> { +//! # Err(InvalidInputError.into()) +//! # } +//! # +//! # fn example() -> Result<(), PublicError> { +//! # process()?; +//! # Ok(()) +//! # } //! ``` //! //! - See also the [`anyhow`] library for a convenient single error type to use