diff options
| author | rtkay123 <dev@kanjala.com> | 2026-02-02 13:05:49 +0200 |
|---|---|---|
| committer | rtkay123 <dev@kanjala.com> | 2026-02-02 13:05:49 +0200 |
| commit | e06094f23ca861ea5ae4864d11fa8ce8b7d7aa2c (patch) | |
| tree | 27bbff5fd21711f99aaf579a76b1a0aca7869003 /src/server/error/mod.rs | |
| parent | 78f61ccdf66572d7432b5b627994038479103653 (diff) | |
| download | sellershut-e06094f23ca861ea5ae4864d11fa8ce8b7d7aa2c.tar.bz2 sellershut-e06094f23ca861ea5ae4864d11fa8ce8b7d7aa2c.zip | |
feat: oauth route
Diffstat (limited to 'src/server/error/mod.rs')
| -rw-r--r-- | src/server/error/mod.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/server/error/mod.rs b/src/server/error/mod.rs new file mode 100644 index 0000000..6d07f9f --- /dev/null +++ b/src/server/error/mod.rs @@ -0,0 +1,27 @@ +use axum::{ + http::StatusCode, + response::{IntoResponse, Response}, +}; + +#[derive(Debug)] +pub struct AppError(anyhow::Error); + +// Tell axum how to convert `AppError` into a response. +impl IntoResponse for AppError { + fn into_response(self) -> Response { + tracing::error!("Application error: {:#}", self.0); + + (StatusCode::INTERNAL_SERVER_ERROR, "Something went wrong").into_response() + } +} + +// This enables using `?` on functions that return `Result<_, anyhow::Error>` to turn them into +// `Result<_, AppError>`. That way you don't need to do that manually. +impl<E> From<E> for AppError +where + E: Into<anyhow::Error>, +{ + fn from(err: E) -> Self { + Self(err.into()) + } +} |
