aboutsummaryrefslogblamecommitdiffstats
path: root/src/error.rs
blob: 890a148623973ad3432bd2ffa5f718a71bf4de77 (plain) (tree)
1
2
3
4
5
6
7
8
                                      


                           



                                                                   



                                            
                                                  




                                                 
                                                       




                                                   
                                                      

     
use rocket::{http::Status, Responder};

#[derive(Responder, Debug)]
pub enum BlossomError {
    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(Status::new(500), e)
    }
}

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

impl From<mastodon_async::Error> for BlossomError {
    fn from(e: mastodon_async::Error) -> Self {
        BlossomError::Skinnyverse(Status::new(500), e)
    }
}