logo
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use actix_web::http::StatusCode;
use actix_web::{HttpResponse, ResponseError};
use thiserror::Error;

#[derive(Debug, Error)]
pub enum PrerenderError {
    #[error("Invalid Url.")]
    InvalidUrl,

    #[error(transparent)]
    ReqwestError(#[from] reqwest::Error),
}

impl ResponseError for PrerenderError {
    fn status_code(&self) -> StatusCode {
        StatusCode::BAD_REQUEST
    }

    fn error_response(&self) -> HttpResponse {
        let res = HttpResponse::with_body(self.status_code(), self.to_string());
        res.map_into_boxed_body()
    }
}