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
30
31
32
33
34
35
36
37
38
39
40
41
42
use actix_web::{http::StatusCode, HttpResponse, ResponseError};
use derive_more::Display;
#[derive(Display, Debug, PartialEq)]
pub enum FilesError {
#[allow(dead_code)]
#[display(fmt = "Path is not a directory. Unable to serve static files")]
IsNotDirectory,
#[display(fmt = "Unable to render directory without index file")]
IsDirectory,
}
impl ResponseError for FilesError {
fn error_response(&self) -> HttpResponse {
HttpResponse::new(StatusCode::NOT_FOUND)
}
}
#[derive(Display, Debug, PartialEq)]
pub enum UriSegmentError {
#[display(fmt = "The segment started with the wrapped invalid character")]
BadStart(char),
#[display(fmt = "The segment contained the wrapped invalid character")]
BadChar(char),
#[display(fmt = "The segment ended with the wrapped invalid character")]
BadEnd(char),
}
impl ResponseError for UriSegmentError {
fn status_code(&self) -> StatusCode {
StatusCode::BAD_REQUEST
}
}