Skip to content

Commit

Permalink
feat(homeserver): internal server errors should be logged first
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuhvi committed Sep 27, 2024
1 parent d39e3b9 commit 6e42cd3
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pubky-homeserver/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use axum::{
http::StatusCode,
response::IntoResponse,
};
use tracing::debug;

pub type Result<T, E = Error> = core::result::Result<T, E>;

Expand Down Expand Up @@ -86,36 +87,42 @@ impl From<pkarr::Error> for Error {

impl From<std::io::Error> for Error {
fn from(error: std::io::Error) -> Self {
debug!(?error);
Self::new(StatusCode::INTERNAL_SERVER_ERROR, error.into())
}
}

impl From<heed::Error> for Error {
fn from(error: heed::Error) -> Self {
debug!(?error);
Self::new(StatusCode::INTERNAL_SERVER_ERROR, error.into())
}
}

impl From<anyhow::Error> for Error {
fn from(error: anyhow::Error) -> Self {
debug!(?error);
Self::new(StatusCode::INTERNAL_SERVER_ERROR, error.into())
}
}

impl From<postcard::Error> for Error {
fn from(error: postcard::Error) -> Self {
debug!(?error);
Self::new(StatusCode::INTERNAL_SERVER_ERROR, error.into())
}
}

impl From<axum::Error> for Error {
fn from(error: axum::Error) -> Self {
debug!(?error);
Self::new(StatusCode::INTERNAL_SERVER_ERROR, error.into())
}
}

impl<T> From<flume::SendError<T>> for Error {
fn from(error: flume::SendError<T>) -> Self {
debug!(?error);
Self::new(StatusCode::INTERNAL_SERVER_ERROR, error.into())
}
}

0 comments on commit 6e42cd3

Please sign in to comment.