From e55565cb3841bf17cf7b8a5e5cf84e59e4372e11 Mon Sep 17 00:00:00 2001 From: Owen Jacobson Date: Wed, 9 Oct 2024 22:52:42 -0400 Subject: Normalize `not found` errors a bit. --- src/error.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/error.rs') diff --git a/src/error.rs b/src/error.rs index 8792a1d..85573d4 100644 --- a/src/error.rs +++ b/src/error.rs @@ -69,3 +69,15 @@ impl IntoResponse for Unauthorized { (StatusCode::UNAUTHORIZED, "unauthorized").into_response() } } + +pub struct NotFound(pub E); + +impl IntoResponse for NotFound +where + E: std::error::Error, +{ + fn into_response(self) -> Response { + let Self(response) = self; + (StatusCode::NOT_FOUND, response.to_string()).into_response() + } +} -- cgit v1.2.3