1use actix_web::{http::StatusCode, ResponseError};
2use derive_more::Display;
3
4#[derive(Debug, PartialEq, Eq, Display)]
6pub enum FilesError {
7 #[allow(dead_code)]
9 #[display("path is not a directory. Unable to serve static files")]
10 IsNotDirectory,
11
12 #[display("unable to render directory without index file")]
14 IsDirectory,
15}
16
17impl ResponseError for FilesError {
18 fn status_code(&self) -> StatusCode {
20 StatusCode::NOT_FOUND
21 }
22}
23
24#[derive(Debug, PartialEq, Eq, Display)]
26#[non_exhaustive]
27pub enum UriSegmentError {
28 #[display("segment started with invalid character: ('{_0}')")]
30 BadStart(char),
31
32 #[display("segment contained invalid character ('{_0}')")]
34 BadChar(char),
35
36 #[display("segment ended with invalid character: ('{_0}')")]
38 BadEnd(char),
39
40 #[display("path is not a valid UTF-8 string after percent-decoding")]
42 NotValidUtf8,
43}
44
45impl ResponseError for UriSegmentError {
46 fn status_code(&self) -> StatusCode {
48 StatusCode::BAD_REQUEST
49 }
50}