diff options
| author | WriterV2 <primary-v2@protonmail.com> | 2024-10-27 13:58:51 +0100 |
|---|---|---|
| committer | WriterV2 <primary-v2@protonmail.com> | 2024-10-27 14:00:34 +0100 |
| commit | 04e19765aca471fd85199714699aaf827d04608d (patch) | |
| tree | a2bfa782c1db2a6b783206087309a9eed3c6e9b9 /src/error.rs | |
| parent | e074949d96fe29929e99890b3035dc1a5ba57184 (diff) | |
Refactor: Organize modules initially
Diffstat (limited to 'src/error.rs')
| -rw-r--r-- | src/error.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/error.rs b/src/error.rs new file mode 100644 index 0000000..72378ae --- /dev/null +++ b/src/error.rs @@ -0,0 +1,23 @@ +use axum::http::StatusCode; +use axum::response::IntoResponse; + +pub struct AppError(anyhow::Error); + +impl IntoResponse for AppError { + fn into_response(self) -> axum::response::Response { + ( + StatusCode::INTERNAL_SERVER_ERROR, + format!("Something went wrong: {}", self.0), + ) + .into_response() + } +} + +impl<E> From<E> for AppError +where + E: Into<anyhow::Error>, +{ + fn from(err: E) -> Self { + Self(err.into()) + } +} |
