actix_prerender/
error.rs

1use actix_web::http::StatusCode;
2use actix_web::{HttpResponse, ResponseError};
3use thiserror::Error;
4
5#[derive(Debug, Error)]
6pub enum PrerenderError {
7    #[error("Invalid Url.")]
8    InvalidUrl,
9
10    #[error(transparent)]
11    ReqwestError(#[from] reqwest::Error),
12}
13
14impl ResponseError for PrerenderError {
15    fn status_code(&self) -> StatusCode {
16        StatusCode::BAD_REQUEST
17    }
18
19    fn error_response(&self) -> HttpResponse {
20        let res = HttpResponse::with_body(self.status_code(), self.to_string());
21        res.map_into_boxed_body()
22    }
23}