use actix_web::{http::StatusCode, ResponseError};
use derive_more::Display;
#[derive(Debug, PartialEq, Eq, Display)]
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 status_code(&self) -> StatusCode {
StatusCode::NOT_FOUND
}
}
#[allow(clippy::enum_variant_names)]
#[derive(Debug, PartialEq, Eq, Display)]
#[non_exhaustive]
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),
#[display(fmt = "The path is not a valid UTF-8 string after percent-decoding")]
NotValidUtf8,
}
impl ResponseError for UriSegmentError {
fn status_code(&self) -> StatusCode {
StatusCode::BAD_REQUEST
}
}