thiserror — derive macro for Error. anyhow — dynamic error type.
thiserror:
anyhow:
1use thiserror::Error;23#[derive(Error, Debug)]4enum MyError {5 #[error("not found")]6 NotFound,7 #[error("io error: {0}")]8 Io(#[from] std::io::Error),9}
Key: thiserror for library errors, anyhow for application errors.