Repository: actix/actix-web
File: src/error.rs (Rust)

Code before:
pub enum UrlGenerationError {
    /// Resource not found
    #[fail(display = "Resource not found")]
    ResourceNotFound,
    /// Not all path pattern covered
    #[fail(display = "Not all path pattern covered")]
    NotEnoughElements,
    /// URL parse error
    #[fail(display = "{}", _0)]
    ParseError(#[cause] UrlParseError),
}

/// `InternalServerError` for `UrlGeneratorError`
impl ResponseError for UrlGenerationError {}

impl From<UrlParseError> for UrlGenerationError {
    fn from(err: UrlParseError) -> Self {
        UrlGenerationError::ParseError(err)
    }
}

/// Errors which can occur when serving static files.
#[derive(Fail, Debug, PartialEq)]
pub enum StaticFileError {
    /// Path is not a directory
    #[fail(display = "Path is not a directory")]
    IsNotDirectory,
    /// Cannot render directory
    #[fail(display = "Cannot render directory")]
    IsDirectory,
}

/// Return `NotFound` for `StaticFileError`
impl ResponseError for StaticFileError {
    fn error_response(&self) -> HttpResponse {
        HttpResponse::new(StatusCode::NOT_FOUND)
    }
}

/// Helper type that can wrap any error and generate custom response.
///
/// In following example any `io::Error` will be converted into "BAD REQUEST"
/// response as opposite to *INTERNAL SERVER ERROR* which is defined by
/// default.
///
/// ```rust
/// # extern crate actix_web;
/// # use actix_web::*;
/// use actix_web::fs::NamedFile;
///
/// fn index(req: HttpRequest) -> Result<fs::NamedFile> {

Review comment (suggestion):
Please expand the error description: `Path is not a directory. Unable to serve static files`

Code after:
pub enum UrlGenerationError {
    /// Resource not found
    #[fail(display = "Resource not found")]
    ResourceNotFound,
    /// Not all path pattern covered
    #[fail(display = "Not all path pattern covered")]
    NotEnoughElements,
    /// URL parse error
    #[fail(display = "{}", _0)]
    ParseError(#[cause] UrlParseError),
}

/// `InternalServerError` for `UrlGeneratorError`
impl ResponseError for UrlGenerationError {}

impl From<UrlParseError> for UrlGenerationError {
    fn from(err: UrlParseError) -> Self {
        UrlGenerationError::ParseError(err)
    }
}

/// Errors which can occur when serving static files.
#[derive(Fail, Debug, PartialEq)]
pub enum StaticFileError {
    /// Path is not a directory
    #[fail(display = "Path is not a directory. Unable to serve static files")]
    IsNotDirectory,
    /// Cannot render directory
    #[fail(display = "Unable to render directory without index file")]
    IsDirectory,
}

/// Return `NotFound` for `StaticFileError`
impl ResponseError for StaticFileError {
    fn error_response(&self) -> HttpResponse {
        HttpResponse::new(StatusCode::NOT_FOUND)
    }
}

/// Helper type that can wrap any error and generate custom response.
///
/// In following example any `io::Error` will be converted into "BAD REQUEST"
/// response as opposite to *INTERNAL SERVER ERROR* which is defined by
/// default.
///
/// ```rust
/// # extern crate actix_web;
/// # use actix_web::*;
/// use actix_web::fs::NamedFile;
///
/// fn index(req: HttpRequest) -> Result<fs::NamedFile> {