mirror of https://github.com/fafhrd91/actix-web
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 <otavio@ossystems.com.br>
This commit is contained in:
parent
b4047ae053
commit
496626929d
|
@ -24,12 +24,12 @@ actix-service = "1.0.1"
|
||||||
bitflags = "1"
|
bitflags = "1"
|
||||||
bytes = "0.5.3"
|
bytes = "0.5.3"
|
||||||
futures = "0.3.1"
|
futures = "0.3.1"
|
||||||
derive_more = "0.99.2"
|
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
mime = "0.3"
|
mime = "0.3"
|
||||||
mime_guess = "2.0.1"
|
mime_guess = "2.0.1"
|
||||||
percent-encoding = "2.1"
|
percent-encoding = "2.1"
|
||||||
v_htmlescape = "0.4"
|
v_htmlescape = "0.4"
|
||||||
|
thiserror = "1.0.11"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
actix-rt = "1.0.0"
|
actix-rt = "1.0.0"
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
use actix_web::{http::StatusCode, HttpResponse, ResponseError};
|
use actix_web::{http::StatusCode, HttpResponse, ResponseError};
|
||||||
use derive_more::Display;
|
use thiserror::Error;
|
||||||
|
|
||||||
/// Errors which can occur when serving static files.
|
/// Errors which can occur when serving static files.
|
||||||
#[derive(Display, Debug, PartialEq)]
|
#[derive(Error, Debug, PartialEq)]
|
||||||
pub enum FilesError {
|
pub enum FilesError {
|
||||||
/// Path is not a directory
|
/// Path is not a directory
|
||||||
#[allow(dead_code)]
|
#[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,
|
IsNotDirectory,
|
||||||
|
|
||||||
/// Cannot render directory
|
/// Cannot render directory
|
||||||
#[display(fmt = "Unable to render directory without index file")]
|
#[error("Unable to render directory without index file")]
|
||||||
IsDirectory,
|
IsDirectory,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,16 +21,16 @@ impl ResponseError for FilesError {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Display, Debug, PartialEq)]
|
#[derive(Error, Debug, PartialEq)]
|
||||||
pub enum UriSegmentError {
|
pub enum UriSegmentError {
|
||||||
/// The segment started with the wrapped invalid character.
|
/// 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),
|
BadStart(char),
|
||||||
/// The segment contained the wrapped invalid character.
|
/// 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),
|
BadChar(char),
|
||||||
/// The segment ended with the wrapped invalid character.
|
/// 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),
|
BadEnd(char),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue