diff options
author | cel 🌸 <cel@blos.sm> | 2023-02-16 18:02:20 +0000 |
---|---|---|
committer | cel 🌸 <cel@blos.sm> | 2023-02-16 18:02:20 +0000 |
commit | 675081e9d28ab7f072e82446a52a8bd26382ed66 (patch) | |
tree | 45574a4245eb41b940fc241cdd6b560f10576686 /src/error.rs | |
parent | 059cf500e7cd98de88c59d6824354a3d2d87fc89 (diff) | |
download | blossom-675081e9d28ab7f072e82446a52a8bd26382ed66.tar.gz blossom-675081e9d28ab7f072e82446a52a8bd26382ed66.tar.bz2 blossom-675081e9d28ab7f072e82446a52a8bd26382ed66.zip |
improve error handling
Diffstat (limited to 'src/error.rs')
-rw-r--r-- | src/error.rs | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/error.rs b/src/error.rs index 38802d3..890a148 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,29 +1,27 @@ -use rocket::Responder; +use rocket::{http::Status, Responder}; #[derive(Responder, Debug)] pub enum BlossomError { - #[response(status = 500)] - Reqwest(&'static str, #[response(ignore)] reqwest::Error), - #[response(status = 500)] - ListenBrainz(&'static str, #[response(ignore)] listenbrainz::Error), - #[response(status = 500)] - Skinnyverse(&'static str, #[response(ignore)] mastodon_async::Error), + Reqwest(Status, #[response(ignore)] reqwest::Error), + ListenBrainz(Status, #[response(ignore)] listenbrainz::Error), + Skinnyverse(Status, #[response(ignore)] mastodon_async::Error), + Unimplemented(Status), } impl From<reqwest::Error> for BlossomError { fn from(e: reqwest::Error) -> Self { - BlossomError::Reqwest("reqwest error", e) + BlossomError::Reqwest(Status::new(500), e) } } impl From<listenbrainz::Error> for BlossomError { fn from(e: listenbrainz::Error) -> Self { - BlossomError::ListenBrainz("listenbrainz error", e) + BlossomError::ListenBrainz(Status::new(500), e) } } impl From<mastodon_async::Error> for BlossomError { fn from(e: mastodon_async::Error) -> Self { - BlossomError::Skinnyverse("skinnyverse error", e) + BlossomError::Skinnyverse(Status::new(500), e) } } |