remove failure

This commit is contained in:
Rob Ede 2020-09-29 00:28:58 +01:00
parent 9a1bee0eba
commit 820a3cfd28
No known key found for this signature in database
GPG key ID: C2A3B36E841A91E6
17 changed files with 39 additions and 138 deletions

109
Cargo.lock generated
View file

@ -6,47 +6,24 @@ version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2692800d602527d2b8fea50036119c37df74ab565b10e285706a3dcec0ec3e16"
[[package]]
name = "addr2line"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b6a2d3371669ab3ca9797670853d61402b03d0b4b9ebf33d677dfa720203072"
dependencies = [
"gimli",
]
[[package]]
name = "adler"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e"
[[package]]
name = "antidote"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34fde25430d87a9388dadbe6e34d7f72a462c8b43ac8d309b42b0a8505d7e2a5"
[[package]]
name = "anyhow"
version = "1.0.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6b602bfe940d21c130f3895acd65221e8a61270debe89d628b9cb4e3ccb8569b"
[[package]]
name = "autocfg"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
[[package]]
name = "backtrace"
version = "0.3.50"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46254cf2fdcdf1badb5934448c1bcbe046a56537b3987d96c51a7afc5d03f293"
dependencies = [
"addr2line",
"cfg-if",
"libc",
"miniz_oxide",
"object",
"rustc-demangle",
]
[[package]]
name = "badge"
version = "0.2.0"
@ -269,28 +246,6 @@ version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "134951f4028bdadb9b84baf4232681efbf277da25144b9b0ad65df75946c422b"
[[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 = "fake-simd"
version = "0.1.2"
@ -365,12 +320,6 @@ dependencies = [
"typenum",
]
[[package]]
name = "gimli"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724"
[[package]]
name = "hashbrown"
version = "0.9.1"
@ -652,16 +601,6 @@ version = "0.3.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d"
[[package]]
name = "miniz_oxide"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c60c0dfe32c10b43a144bad8fc83538c52f58302c92300ea7ec7bf7b38d5a7b9"
dependencies = [
"adler",
"autocfg",
]
[[package]]
name = "mio"
version = "0.6.22"
@ -768,12 +707,6 @@ dependencies = [
"libc",
]
[[package]]
name = "object"
version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ab52be62400ca80aa00285d25253d7f7c437b7375c4de678f5405d3afe82ca5"
[[package]]
name = "once_cell"
version = "1.4.1"
@ -1021,12 +954,6 @@ version = "0.1.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea509065eb0b3c446acdd0102f0d46567dc30902dc0be91d6552035d92b0f4f8"
[[package]]
name = "rustc-demangle"
version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783"
[[package]]
name = "rustc_version"
version = "0.2.3"
@ -1243,23 +1170,14 @@ dependencies = [
"opaque-debug",
]
[[package]]
name = "shared_failure"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95950ce835eb54ad4d85f5f597a3d7f78cb0f6622f65dabc2dac915d9edc404a"
dependencies = [
"failure",
]
[[package]]
name = "shiny-robots"
version = "0.1.0"
dependencies = [
"anyhow",
"badge",
"cadence",
"derive_more",
"failure",
"futures",
"hyper 0.11.27",
"hyper-tls",
@ -1274,7 +1192,6 @@ dependencies = [
"semver 0.11.0",
"serde 1.0.116",
"serde_json 1.0.57",
"shared_failure",
"slog",
"slog-json",
"tokio-core",
@ -1339,18 +1256,6 @@ dependencies = [
"unicode-xid",
]
[[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 = "take"
version = "0.1.0"

View file

@ -13,9 +13,9 @@ members = [
[dependencies]
badge = { path = "./libs/badge" }
anyhow = "1"
cadence = "0.13"
derive_more = "0.99"
failure = "0.1"
futures = "0.1"
hyper = "0.11"
hyper-tls = "0.1"
@ -29,7 +29,6 @@ rustsec = "0.6.0"
semver = { version = "0.11", features = ["serde"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
shared_failure = "0.1"
slog = "2"
slog-json = "2"
tokio-core = "0.1"

View file

@ -1,4 +1,4 @@
use failure::Error;
use anyhow::{anyhow, ensure, Error};
use futures::stream::futures_unordered;
use futures::{Future, Poll, Stream};

View file

@ -1,6 +1,6 @@
use std::mem;
use failure::Error;
use anyhow::{anyhow, ensure, Error};
use futures::stream::FuturesOrdered;
use futures::{try_ready, Async, Future, Poll, Stream};
use relative_path::RelativePathBuf;

View file

@ -1,6 +1,6 @@
use std::collections::HashMap;
use failure::Error;
use anyhow::{anyhow, ensure, Error};
use indexmap::IndexMap;
use relative_path::RelativePathBuf;

View file

@ -4,7 +4,7 @@ use std::time::{Duration, Instant};
use cadence::prelude::*;
use cadence::{MetricSink, NopMetricSink, StatsdClient};
use failure::Error;
use anyhow::{anyhow, ensure, Error};
use futures::future::join_all;
use futures::{future, Future};
use hyper::client::HttpConnector;
@ -176,7 +176,7 @@ impl Engine {
.iter()
.find(|release| release.version == crate_path.version)
{
None => future::Either::A(future::err(format_err!(
None => future::Either::A(future::err(anyhow!(
"could not find crate release with version {}",
crate_path.version
))),

View file

@ -1,4 +1,4 @@
use failure::Error;
use anyhow::{anyhow, ensure, Error};
use hyper::Uri;
use relative_path::RelativePathBuf;

View file

@ -1,6 +1,6 @@
use std::str;
use failure::Error;
use anyhow::{anyhow, ensure, Error};
use futures::{future, Future, IntoFuture, Stream};
use hyper::{Error as HyperError, Method, Request, Response, Uri};
use semver::{Version, VersionReq};
@ -100,7 +100,7 @@ where
Box::new(self.0.call(request).from_err().and_then(move |response| {
let status = response.status();
if !status.is_success() {
try_future!(Err(format_err!("Status code {} for URI {}", status, uri)));
try_future!(Err(anyhow!("Status code {} for URI {}", status, uri)));
}
let body_future = response.body().concat2().from_err();
@ -174,7 +174,7 @@ where
service.call(request).from_err().and_then(move |response| {
let status = response.status();
if !status.is_success() {
future::Either::A(future::err(format_err!(
future::Either::A(future::err(anyhow!(
"Status code {} for URI {}",
status,
uri

View file

@ -1,4 +1,4 @@
use failure::Error;
use anyhow::{anyhow, ensure, Error};
use futures::{Future, Stream};
use hyper::header::UserAgent;
use hyper::{Error as HyperError, Method, Request, Response, Uri};
@ -66,7 +66,7 @@ where
Box::new(self.0.call(request).from_err().and_then(|response| {
let status = response.status();
if !status.is_success() {
try_future!(Err(format_err!(
try_future!(Err(anyhow!(
"Status code {} for popular repo search",
status
)));

View file

@ -1,4 +1,4 @@
use failure::Error;
use anyhow::{anyhow, ensure, Error};
use hyper::Uri;
use relative_path::RelativePathBuf;

View file

@ -1,4 +1,4 @@
use failure::Error;
use anyhow::{anyhow, ensure, Error};
use futures::{Future, Stream};
use hyper::{Error as HyperError, Method, Request, Response};
use relative_path::RelativePathBuf;
@ -38,7 +38,7 @@ where
Box::new(self.0.call(request).from_err().and_then(move |response| {
let status = response.status();
if !status.is_success() {
try_future!(Err(format_err!("Status code {} for URI {}", status, uri)));
try_future!(Err(anyhow!("Status code {} for URI {}", status, uri)));
}
let body_future = response.body().concat2().from_err();

View file

@ -1,7 +1,7 @@
use std::str;
use std::sync::Arc;
use failure::Error;
use anyhow::{anyhow, ensure, Error};
use futures::{future, Future, IntoFuture, Stream};
use hyper::{Error as HyperError, Method, Request, Response};
use rustsec::db::AdvisoryDatabase;
@ -32,7 +32,7 @@ where
service.call(request).from_err().and_then(|response| {
let status = response.status();
if !status.is_success() {
future::Either::A(future::err(format_err!(
future::Either::A(future::err(anyhow!(
"Status code {} when fetching advisory db",
status
)))

View file

@ -1,7 +1,7 @@
#![deny(rust_2018_idioms)]
#![allow(unused)]
#[macro_use]
extern crate failure;
#[macro_use]
extern crate try_future;

View file

@ -1,7 +1,7 @@
use std::borrow::Borrow;
use std::str::FromStr;
use failure::Error;
use anyhow::{anyhow, ensure, Error};
use indexmap::IndexMap;
use relative_path::RelativePathBuf;
use semver::{Version, VersionReq};
@ -51,7 +51,7 @@ impl FromStr for CrateName {
.all(|c| c.is_ascii_alphanumeric() || c == '_' || c == '-');
if !is_valid {
Err(format_err!("failed to validate crate name: {}", input))
Err(anyhow!("failed to validate crate name: {}", input))
} else {
Ok(CrateName(input.to_string()))
}

View file

@ -1,6 +1,6 @@
use std::str::FromStr;
use failure::Error;
use anyhow::{anyhow, ensure, Error};
#[derive(Clone, Debug)]
pub struct Repository {
@ -50,7 +50,7 @@ impl FromStr for RepoSite {
"github" => Ok(RepoSite::Github),
"gitlab" => Ok(RepoSite::Gitlab),
"bitbucket" => Ok(RepoSite::Bitbucket),
_ => Err(format_err!("unknown repo site identifier")),
_ => Err(anyhow!("unknown repo site identifier")),
}
}
}

View file

@ -1,4 +1,4 @@
use failure::Error;
use anyhow::{anyhow, ensure, Error};
use indexmap::IndexMap;
use relative_path::RelativePathBuf;
use semver::VersionReq;
@ -132,9 +132,7 @@ pub fn parse_manifest_toml(input: &str) -> Result<CrateManifest, Error> {
deps,
members,
}),
(None, None) => Err(format_err!(
"neither workspace nor package found in manifest"
)),
(None, None) => Err(anyhow!("neither workspace nor package found in manifest")),
}
}

View file

@ -4,11 +4,10 @@ use std::ops::Deref;
use std::sync::Mutex;
use std::time::{Duration, Instant};
use failure::Error;
use anyhow::{anyhow, ensure, Error};
use futures::future::{FromErr, Shared, SharedItem};
use futures::{Future, Poll};
use lru_cache::LruCache;
use shared_failure::SharedFailure;
use tokio_service::Service;
pub struct Cache<S>
@ -18,7 +17,7 @@ where
{
inner: S,
duration: Duration,
cache: Mutex<LruCache<S::Request, (Instant, Shared<FromErr<S::Future, SharedFailure>>)>>,
cache: Mutex<LruCache<S::Request, (Instant, Shared<FromErr<S::Future, Error>>)>>,
}
impl<S> Debug for Cache<S>
@ -55,7 +54,7 @@ where
{
type Request = S::Request;
type Response = CachedItem<S::Response>;
type Error = SharedFailure;
type Error = Error;
type Future = Cached<S::Future>;
fn call(&self, req: Self::Request) -> Self::Future {
@ -74,7 +73,7 @@ where
}
}
pub struct Cached<F: Future<Error = Error>>(Shared<FromErr<F, SharedFailure>>);
pub struct Cached<F: Future<Error = Error>>(Shared<FromErr<F, Error>>);
impl<F> Debug for Cached<F>
where
@ -88,13 +87,13 @@ where
impl<F: Future<Error = Error>> Future for Cached<F> {
type Item = CachedItem<F::Item>;
type Error = SharedFailure;
type Error = Error;
fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
self.0
.poll()
.map_err(|err| (*err).clone())
.map(|_async| _async.map(CachedItem))
.map_err(|_err| anyhow!("TODO: shared error not clone-able"))
.map(|item| item.map(CachedItem))
}
}