3 comments

[ 0.33 ms ] story [ 19.8 ms ] thread
(comment deleted)
This is even easier with the thiserror crate:

   #[derive(Debug, Error)
   enum AppError {
       #[error("io: {0}")]
       Io(#[from] io::Error)
   }
Automatically generates From impls like this and a Display impl that lets you describe the error case with more detail. Very very good ergonomics and completely transparent to downstream libraries.