Skip to content

anyhow instead of error_chain #2721

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
366 changes: 139 additions & 227 deletions Cargo.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ anyhow = "1.0.31"
cfg-if = "1.0"
chrono = "0.4"
clap = "2"
download = { path = "download", default-features = false }
download = {path = "download", default-features = false}
effective-limits = "0.5.2"
error-chain = "0.12"
flate2 = "1"
git-testament = "0.1.4"
home = {git = "https://github.com/rbtcollins/home", rev = "a243ee2fbee6022c57d56f5aa79aefe194eabe53"}
Expand All @@ -43,6 +42,7 @@ opener = "0.4.0"
# Used by `curl` or `reqwest` backend although it isn't imported
# by our rustup.
openssl = {version = "0.10", optional = true}
pgp = {version = "0.7", default-features = false}
pulldown-cmark = {version = "0.8", default-features = false}
rand = "0.8"
regex = "1"
Expand All @@ -55,9 +55,9 @@ sha2 = "0.9"
strsim = "0.10"
tar = "0.4.26"
tempfile = "3.1"
pgp = {version = "0.7", default-features = false}
# FIXME(issue #1818, #1826, and friends)
term = "=0.5.1"
thiserror = "1.0"
threadpool = "1"
toml = "0.5"
url = "2.1"
Expand All @@ -68,7 +68,7 @@ zstd = "0.6"
[dependencies.retry]
default-features = false
features = ["random"]
version = "1"
version = "1.2.1"

[dependencies.rs_tracing]
features = ["rs_tracing"]
Expand Down
22 changes: 11 additions & 11 deletions download/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
[package]

name = "download"
version = "0.6.9"
authors = ["Brian Anderson <[email protected]>"]
edition = "2018"
authors = [ "Brian Anderson <[email protected]>" ]

license = "MIT/Apache-2.0"
name = "download"
version = "0.6.9"

[features]

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

[dependencies]
error-chain = "0.12"
anyhow = "1.0.31"
curl = {version = "0.4.11", optional = true}
env_proxy = {version = "0.4.1", optional = true}
lazy_static = {version = "1.0", optional = true}
reqwest = {version = "0.11", default-features = false, features = ["blocking", "gzip", "socks"], optional = true}
thiserror = "1.0"
url = "2.1"
curl = { version = "0.4.11", optional = true }
env_proxy = { version = "0.4.1", optional = true }
lazy_static = { version = "1.0", optional = true }
reqwest = { version = "0.11", default-features = false, features = ["blocking", "gzip", "socks"], optional = true }

[dev-dependencies]
hyper = { version = "0.14", default-features = false, features = ["tcp", "server"] }
hyper = {version = "0.14", default-features = false, features = ["tcp", "server"]}
tempfile = "3"
tokio = { version = "1", default-features = false, features = ["sync"] }
tokio = {version = "1", default-features = false, features = ["sync"]}
41 changes: 18 additions & 23 deletions download/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
#![allow(deprecated)] // because of `Error::description` deprecation in `error_chain`
use error_chain::error_chain;
use thiserror::Error;

error_chain! {
links { }

foreign_links {
Io(std::io::Error);
Reqwest(::reqwest::Error) #[cfg(feature = "reqwest-backend")];
}

errors {
HttpStatus(e: u32) {
description("http request returned an unsuccessful status code")
display("http request returned an unsuccessful status code: {}", e)
}
FileNotFound {
description("file not found")
}
BackendUnavailable(be: &'static str) {
description("download backend unavailable")
display("download backend '{}' unavailable", be)
}
}
#[derive(Debug, Error)]
pub enum DownloadError {
#[error("http request returned an unsuccessful status code: {0}")]
HttpStatus(u32),
#[error("file not found")]
FileNotFound,
#[error("download backend '{0}' unavailable")]
BackendUnavailable(&'static str),
#[error("{0}")]
Message(String),
#[error(transparent)]
IoError(#[from] std::io::Error),
#[cfg(feature = "reqwest-backend")]
#[error(transparent)]
Reqwest(#[from] ::reqwest::Error),
#[error(transparent)]
CurlError(#[from] curl::Error),
}
Loading