diff --git a/examples/actix/src/main.rs b/examples/actix/src/main.rs index f3fba1f..6e18ca9 100644 --- a/examples/actix/src/main.rs +++ b/examples/actix/src/main.rs @@ -83,7 +83,7 @@ async fn make_error() -> Result { /// handlers, and implement the actix ResponseError type. #[derive(Debug)] enum ExampleAppError { - ParseInt(std::num::ParseIntError), + // May have other cases, for e.g. a backend not responding. InternalError, } impl actix_web::error::ResponseError for ExampleAppError { @@ -96,16 +96,9 @@ impl std::fmt::Display for ExampleAppError { write!(o, "{:?}", self) } } -impl std::error::Error for ExampleAppError {} - -impl From for ExampleAppError { - fn from(e: std::num::ParseIntError) -> Self { - ExampleAppError::ParseInt(e) - } -} -impl From for ExampleAppError { - fn from(value: std::io::Error) -> Self { - println!("Internal error: {value}"); +impl From for ExampleAppError { + fn from(value: E) -> Self { + tracing::error!("Internal error: {value}"); ExampleAppError::InternalError } }