Skip to main content

rust_serv/
error.rs

1use std::io;
2use std::net::AddrParseError;
3use thiserror::Error;
4
5/// Error type for the static file server
6#[derive(Error, Debug)]
7pub enum Error {
8    #[error("Configuration error: {0}")]
9    Config(String),
10
11    #[error("IO error: {0}")]
12    Io(#[from] io::Error),
13
14    #[error("HTTP error: {0}")]
15    Http(String),
16
17    #[error("Path security error: {0}")]
18    PathSecurity(String),
19
20    #[error("File not found: {0}")]
21    NotFound(String),
22
23    #[error("Forbidden: {0}")]
24    Forbidden(String),
25
26    #[error("Internal error: {0}")]
27    Internal(String),
28
29    #[error("Address parse error: {0}")]
30    AddrParse(#[from] AddrParseError),
31}
32
33/// Result type alias
34pub type Result<T> = std::result::Result<T, Error>;