Skip to content

Commit 7a051f7

Browse files
authored
Merge pull request #2721 from rbtcollins/anyhow
anyhow instead of error_chain
2 parents bc69862 + cf6c9d6 commit 7a051f7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1259
-1718
lines changed

Cargo.lock

+139-227
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,8 @@ anyhow = "1.0.31"
3030
cfg-if = "1.0"
3131
chrono = "0.4"
3232
clap = "2"
33-
download = { path = "download", default-features = false }
33+
download = {path = "download", default-features = false}
3434
effective-limits = "0.5.2"
35-
error-chain = "0.12"
3635
flate2 = "1"
3736
git-testament = "0.1.4"
3837
home = {git = "https://github.com/rbtcollins/home", rev = "a243ee2fbee6022c57d56f5aa79aefe194eabe53"}
@@ -43,6 +42,7 @@ opener = "0.4.0"
4342
# Used by `curl` or `reqwest` backend although it isn't imported
4443
# by our rustup.
4544
openssl = {version = "0.10", optional = true}
45+
pgp = {version = "0.7", default-features = false}
4646
pulldown-cmark = {version = "0.8", default-features = false}
4747
rand = "0.8"
4848
regex = "1"
@@ -55,9 +55,9 @@ sha2 = "0.9"
5555
strsim = "0.10"
5656
tar = "0.4.26"
5757
tempfile = "3.1"
58-
pgp = {version = "0.7", default-features = false}
5958
# FIXME(issue #1818, #1826, and friends)
6059
term = "=0.5.1"
60+
thiserror = "1.0"
6161
threadpool = "1"
6262
toml = "0.5"
6363
url = "2.1"
@@ -68,7 +68,7 @@ zstd = "0.6"
6868
[dependencies.retry]
6969
default-features = false
7070
features = ["random"]
71-
version = "1"
71+
version = "1.2.1"
7272

7373
[dependencies.rs_tracing]
7474
features = ["rs_tracing"]

download/Cargo.toml

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
[package]
22

3-
name = "download"
4-
version = "0.6.9"
3+
authors = ["Brian Anderson <[email protected]>"]
54
edition = "2018"
6-
authors = [ "Brian Anderson <[email protected]>" ]
7-
85
license = "MIT/Apache-2.0"
6+
name = "download"
7+
version = "0.6.9"
98

109
[features]
1110

@@ -17,14 +16,15 @@ reqwest-default-tls = ["reqwest/default-tls"]
1716
reqwest-rustls-tls = ["reqwest/rustls-tls-native-roots"]
1817

1918
[dependencies]
20-
error-chain = "0.12"
19+
anyhow = "1.0.31"
20+
curl = {version = "0.4.11", optional = true}
21+
env_proxy = {version = "0.4.1", optional = true}
22+
lazy_static = {version = "1.0", optional = true}
23+
reqwest = {version = "0.11", default-features = false, features = ["blocking", "gzip", "socks"], optional = true}
24+
thiserror = "1.0"
2125
url = "2.1"
22-
curl = { version = "0.4.11", optional = true }
23-
env_proxy = { version = "0.4.1", optional = true }
24-
lazy_static = { version = "1.0", optional = true }
25-
reqwest = { version = "0.11", default-features = false, features = ["blocking", "gzip", "socks"], optional = true }
2626

2727
[dev-dependencies]
28-
hyper = { version = "0.14", default-features = false, features = ["tcp", "server"] }
28+
hyper = {version = "0.14", default-features = false, features = ["tcp", "server"]}
2929
tempfile = "3"
30-
tokio = { version = "1", default-features = false, features = ["sync"] }
30+
tokio = {version = "1", default-features = false, features = ["sync"]}

download/src/errors.rs

+18-23
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,20 @@
1-
#![allow(deprecated)] // because of `Error::description` deprecation in `error_chain`
2-
use error_chain::error_chain;
1+
use thiserror::Error;
32

4-
error_chain! {
5-
links { }
6-
7-
foreign_links {
8-
Io(std::io::Error);
9-
Reqwest(::reqwest::Error) #[cfg(feature = "reqwest-backend")];
10-
}
11-
12-
errors {
13-
HttpStatus(e: u32) {
14-
description("http request returned an unsuccessful status code")
15-
display("http request returned an unsuccessful status code: {}", e)
16-
}
17-
FileNotFound {
18-
description("file not found")
19-
}
20-
BackendUnavailable(be: &'static str) {
21-
description("download backend unavailable")
22-
display("download backend '{}' unavailable", be)
23-
}
24-
}
3+
#[derive(Debug, Error)]
4+
pub enum DownloadError {
5+
#[error("http request returned an unsuccessful status code: {0}")]
6+
HttpStatus(u32),
7+
#[error("file not found")]
8+
FileNotFound,
9+
#[error("download backend '{0}' unavailable")]
10+
BackendUnavailable(&'static str),
11+
#[error("{0}")]
12+
Message(String),
13+
#[error(transparent)]
14+
IoError(#[from] std::io::Error),
15+
#[cfg(feature = "reqwest-backend")]
16+
#[error(transparent)]
17+
Reqwest(#[from] ::reqwest::Error),
18+
#[error(transparent)]
19+
CurlError(#[from] curl::Error),
2520
}

0 commit comments

Comments
 (0)