aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven-Hendrik Haase <svenstaro@gmail.com>2021-03-20 22:32:25 +0000
committerSven-Hendrik Haase <svenstaro@gmail.com>2021-03-20 22:32:25 +0000
commit9edc6b3055f20635b4c903da0451073fd26562ae (patch)
tree868cf15935050fb1c1cf85d38a1ae72f4c850ca9
parentMerge pull request #471 from svenstaro/show-hidden (diff)
downloadminiserve-9edc6b3055f20635b4c903da0451073fd26562ae.tar.gz
miniserve-9edc6b3055f20635b4c903da0451073fd26562ae.zip
Switch from failure to thiserror
Diffstat (limited to '')
-rw-r--r--Cargo.lock95
-rw-r--r--Cargo.toml2
-rw-r--r--src/errors.rs45
3 files changed, 20 insertions, 122 deletions
diff --git a/Cargo.lock b/Cargo.lock
index f953eb4..e61c69f 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -315,21 +315,6 @@ dependencies = [
]
[[package]]
-name = "addr2line"
-version = "0.14.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a55f82cfe485775d02112886f4169bde0c5894d75e79ead7eafe7e40a25e45f7"
-dependencies = [
- "gimli",
-]
-
-[[package]]
-name = "adler"
-version = "1.0.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
-
-[[package]]
name = "adler32"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -461,20 +446,6 @@ dependencies = [
]
[[package]]
-name = "backtrace"
-version = "0.3.56"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9d117600f438b1707d4e4ae15d3595657288f8235a0eb593e80ecc98ab34e1bc"
-dependencies = [
- "addr2line",
- "cfg-if 1.0.0",
- "libc",
- "miniz_oxide 0.4.4",
- "object",
- "rustc-demangle",
-]
-
-[[package]]
name = "base-x"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -829,28 +800,6 @@ dependencies = [
]
[[package]]
-name = "failure"
-version = "0.1.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d32e9bd16cc02eae7db7ef620b392808b89f6a5e16bb3497d159c6b92a0f4f86"
-dependencies = [
- "backtrace",
- "failure_derive",
-]
-
-[[package]]
-name = "failure_derive"
-version = "0.1.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn",
- "synstructure",
-]
-
-[[package]]
name = "filetime"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -871,7 +820,7 @@ dependencies = [
"cfg-if 0.1.10",
"crc32fast",
"libc",
- "miniz_oxide 0.3.7",
+ "miniz_oxide",
]
[[package]]
@@ -1065,12 +1014,6 @@ dependencies = [
]
[[package]]
-name = "gimli"
-version = "0.23.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f6503fe142514ca4799d4c26297c4248239fe8838d827db6bd6065c6ed29a6ce"
-
-[[package]]
name = "globset"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1584,7 +1527,6 @@ dependencies = [
"bytesize",
"chrono",
"chrono-humanize",
- "failure",
"futures",
"grass",
"hex",
@@ -1610,6 +1552,7 @@ dependencies = [
"strum",
"strum_macros",
"tar",
+ "thiserror",
"url",
"yansi",
"zip",
@@ -1625,16 +1568,6 @@ dependencies = [
]
[[package]]
-name = "miniz_oxide"
-version = "0.4.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b"
-dependencies = [
- "adler",
- "autocfg 1.0.1",
-]
-
-[[package]]
name = "mio"
version = "0.6.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1803,12 +1736,6 @@ dependencies = [
]
[[package]]
-name = "object"
-version = "0.23.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a9a7ab5d64814df0fe4a4b5ead45ed6c5f181ee3ff04ba344313a6c80446c5d4"
-
-[[package]]
name = "once_cell"
version = "1.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2443,12 +2370,6 @@ dependencies = [
]
[[package]]
-name = "rustc-demangle"
-version = "0.1.18"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6e3bad0ee36814ca07d7968269dd4b7ec89ec2da10c4bb613928d3077083c232"
-
-[[package]]
name = "rustc_version"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2800,18 +2721,6 @@ dependencies = [
]
[[package]]
-name = "synstructure"
-version = "0.12.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn",
- "unicode-xid",
-]
-
-[[package]]
name = "tar"
version = "0.4.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/Cargo.toml b/Cargo.toml
index ea065cb..a5b4fcd 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -33,7 +33,7 @@ serde = { version = "1", features = ["derive"] }
tar = "0.4.33"
futures = "0.3.13"
libflate = "1"
-failure = "0.1.8"
+thiserror = "1"
log = "0.4.14"
strum = "0.20.0"
strum_macros = "0.20.1"
diff --git a/src/errors.rs b/src/errors.rs
index 1330390..3287fc3 100644
--- a/src/errors.rs
+++ b/src/errors.rs
@@ -1,76 +1,65 @@
-use failure::Fail;
+use thiserror::Error;
-#[derive(Debug, Fail)]
+#[derive(Debug, Error)]
pub enum ContextualError {
/// Fully customized errors, not inheriting from any error
- #[fail(display = "{}", _0)]
+ #[error("{0}")]
CustomError(String),
/// Any kind of IO errors
- #[fail(display = "{}\ncaused by: {}", _0, _1)]
+ #[error("{0}\ncaused by: {1}")]
IoError(String, std::io::Error),
/// MultipartError, which might occur during file upload, when processing the multipart request fails
- #[fail(display = "Failed to process multipart request\ncaused by: {}", _0)]
+ #[error("Failed to process multipart request\ncaused by: {0}")]
MultipartError(actix_multipart::MultipartError),
/// Any error related to an invalid path (failed to retrieve entry name, unexpected entry type, etc)
- #[fail(display = "Invalid path\ncaused by: {}", _0)]
+ #[error("Invalid path\ncaused by: {0}")]
InvalidPathError(String),
/// This error might occur if the HTTP credential string does not respect the expected format
- #[fail(
- display = "Invalid format for credentials string. Expected username:password, username:sha256:hash or username:sha512:hash"
- )]
+ #[error("Invalid format for credentials string. Expected username:password, username:sha256:hash or username:sha512:hash")]
InvalidAuthFormat,
/// This error might occure if the hash method is neither sha256 nor sha512
- #[fail(
- display = "{} is not a valid hashing method. Expected sha256 or sha512",
- _0
- )]
+ #[error("{0} is not a valid hashing method. Expected sha256 or sha512")]
InvalidHashMethod(String),
/// This error might occur if the HTTP auth hash password is not a valid hex code
- #[fail(display = "Invalid format for password hash. Expected hex code")]
+ #[error("Invalid format for password hash. Expected hex code")]
InvalidPasswordHash,
/// This error might occur if the HTTP auth password exceeds 255 characters
- #[fail(display = "HTTP password length exceeds 255 characters")]
+ #[error("HTTP password length exceeds 255 characters")]
PasswordTooLongError,
/// This error might occur if the user has unsufficient permissions to create an entry in a given directory
- #[fail(display = "Insufficient permissions to create file in {}", _0)]
+ #[error("Insufficient permissions to create file in {0}")]
InsufficientPermissionsError(String),
/// Any error related to parsing.
- #[fail(display = "Failed to parse {}\ncaused by: {}", _0, _1)]
+ #[error("Failed to parse {0}\ncaused by: {1}")]
ParseError(String, String),
/// This error might occur when the creation of an archive fails
- #[fail(
- display = "An error occured while creating the {}\ncaused by: {}",
- _0, _1
- )]
+ #[error("An error occured while creating the {0}\ncaused by: {1}")]
ArchiveCreationError(String, Box<ContextualError>),
/// This error might occur when the HTTP authentication fails
- #[fail(
- display = "An error occured during HTTP authentication\ncaused by: {}",
- _0
- )]
+ #[error("An error occured during HTTP authentication\ncaused by: {0}")]
HttpAuthenticationError(Box<ContextualError>),
/// This error might occur when the HTTP credentials are not correct
- #[fail(display = "Invalid credentials for HTTP authentication")]
+ #[error("Invalid credentials for HTTP authentication")]
InvalidHttpCredentials,
/// This error might occur when an HTTP request is invalid
- #[fail(display = "Invalid HTTP request\ncaused by: {}", _0)]
+ #[error("Invalid HTTP request\ncaused by: {0}")]
InvalidHttpRequestError(String),
/// This error might occur when trying to access a page that does not exist
- #[fail(display = "Route {} could not be found", _0)]
+ #[error("Route {0} could not be found")]
RouteNotFoundError(String),
}