summaryrefslogtreecommitdiff
path: root/src/error.rs
diff options
context:
space:
mode:
authorKit La Touche <kit@transneptune.net>2024-10-23 21:56:31 -0400
committerKit La Touche <kit@transneptune.net>2024-10-23 21:56:31 -0400
commit1f769855df2d9cf2bca883a0475670f227e3678b (patch)
tree6c94d9c868eb022588a07245df978478034ac5dd /src/error.rs
parent8f360dd9cc45bb14431238ccc5e3d137c020fa7b (diff)
parent461814e5174cef1be3e07b4e4069314e9bcbedd6 (diff)
Merge branch 'main' into wip/mobile
Diffstat (limited to 'src/error.rs')
-rw-r--r--src/error.rs17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/error.rs b/src/error.rs
index 85573d4..f3399c6 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -28,15 +28,20 @@ where
}
}
+impl fmt::Display for Internal {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ let Self(id, _) = self;
+ writeln!(f, "internal server error")?;
+ writeln!(f, "error id: {id}")?;
+ Ok(())
+ }
+}
+
impl IntoResponse for Internal {
fn into_response(self) -> Response {
- let Self(id, error) = self;
+ let Self(id, error) = &self;
eprintln!("hi: [{id}] {error}");
- (
- StatusCode::INTERNAL_SERVER_ERROR,
- format!("internal server error\nerror id: {id}"),
- )
- .into_response()
+ (StatusCode::INTERNAL_SERVER_ERROR, self.to_string()).into_response()
}
}