From 496626929d078d1fd961f8ef3b689c744848867a Mon Sep 17 00:00:00 2001 From: Otavio Salvador Date: Wed, 11 Mar 2020 23:54:40 -0300 Subject: [PATCH] files: Convert from `derive_more` to `thiserror` The `thiserror` has the advantage of implementing `std::error::Error` and it integrates better with the Rust ecosystem. Signed-off-by: Otavio Salvador --- actix-files/Cargo.toml | 2 +- actix-files/src/error.rs | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/actix-files/Cargo.toml b/actix-files/Cargo.toml index ed887e323..37f423502 100644 --- a/actix-files/Cargo.toml +++ b/actix-files/Cargo.toml @@ -24,12 +24,12 @@ actix-service = "1.0.1" bitflags = "1" bytes = "0.5.3" futures = "0.3.1" -derive_more = "0.99.2" log = "0.4" mime = "0.3" mime_guess = "2.0.1" percent-encoding = "2.1" v_htmlescape = "0.4" +thiserror = "1.0.11" [dev-dependencies] actix-rt = "1.0.0" diff --git a/actix-files/src/error.rs b/actix-files/src/error.rs index 9b30cbaa2..d66664504 100644 --- a/actix-files/src/error.rs +++ b/actix-files/src/error.rs @@ -1,16 +1,16 @@ use actix_web::{http::StatusCode, HttpResponse, ResponseError}; -use derive_more::Display; +use thiserror::Error; /// Errors which can occur when serving static files. -#[derive(Display, Debug, PartialEq)] +#[derive(Error, Debug, PartialEq)] pub enum FilesError { /// Path is not a directory #[allow(dead_code)] - #[display(fmt = "Path is not a directory. Unable to serve static files")] + #[error("Path is not a directory. Unable to serve static files")] IsNotDirectory, /// Cannot render directory - #[display(fmt = "Unable to render directory without index file")] + #[error("Unable to render directory without index file")] IsDirectory, } @@ -21,16 +21,16 @@ impl ResponseError for FilesError { } } -#[derive(Display, Debug, PartialEq)] +#[derive(Error, Debug, PartialEq)] pub enum UriSegmentError { /// The segment started with the wrapped invalid character. - #[display(fmt = "The segment started with the wrapped invalid character")] + #[error("The segment started with the wrapped invalid character")] BadStart(char), /// The segment contained the wrapped invalid character. - #[display(fmt = "The segment contained the wrapped invalid character")] + #[error("The segment contained the wrapped invalid character")] BadChar(char), /// The segment ended with the wrapped invalid character. - #[display(fmt = "The segment ended with the wrapped invalid character")] + #[error("The segment ended with the wrapped invalid character")] BadEnd(char), }