aboutsummaryrefslogtreecommitdiffstats
path: root/src/error.rs
blob: 38802d39d1fb57b8e734d49b81b2015a4ac8dfca (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use rocket::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),
}

impl From<reqwest::Error> for BlossomError {
    fn from(e: reqwest::Error) -> Self {
        BlossomError::Reqwest("reqwest error", e)
    }
}

impl From<listenbrainz::Error> for BlossomError {
    fn from(e: listenbrainz::Error) -> Self {
        BlossomError::ListenBrainz("listenbrainz error", e)
    }
}

impl From<mastodon_async::Error> for BlossomError {
    fn from(e: mastodon_async::Error) -> Self {
        BlossomError::Skinnyverse("skinnyverse error", e)
    }
}