Skip to content

Commit

Permalink
Replace failure crate with anyhow+thiserror
Browse files Browse the repository at this point in the history
Failure was [deprecated][0] and suggests anyhow+thiserror to replace
itself in dependent projects.

[0]: rust-lang-deprecated/failure#347
  • Loading branch information
steveej committed Jun 4, 2020
1 parent f70fd56 commit b138286
Show file tree
Hide file tree
Showing 52 changed files with 211 additions and 207 deletions.
68 changes: 43 additions & 25 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion cincinnati/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ commons = { path = "../commons" }
custom_debug_derive = "^0.1.7"
daggy = { version = "^0.6.0", features = [ "serde-1" ] }
env_logger = "^0.6.0"
failure = "^0.1.1"
futures = "0.3"
futures-locks = "0.5.0"
lazy_static = "^1.2.0"
Expand Down
13 changes: 6 additions & 7 deletions cincinnati/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#[macro_use]
extern crate failure;

#[macro_use]
extern crate serde_derive;

#[macro_use]
pub mod plugins;

use commons::prelude_errors::*;
use daggy::petgraph::visit::{IntoNodeReferences, NodeRef};
use daggy::{Dag, EdgeIndex, Walker};
use failure::{Error, Fallible};
use serde::de::{self, Deserialize, Deserializer, MapAccess, Visitor};
use serde::ser::{Serialize, SerializeStruct, Serializer};
use std::{collections, fmt};
Expand Down Expand Up @@ -154,25 +151,27 @@ pub struct Empty;

/// Errors that can be returned by the methods in this library
pub mod errors {
use commons::prelude_errors::*;

/// Edge already exists
#[derive(Debug, Fail, Eq, PartialEq)]
#[fail(display = "edge from {:?} to {:?} already exists", from, to)]
#[error("edge from {:?} to {:?} already exists", from, to)]
pub struct EdgeAlreadyExists {
pub(crate) from: String,
pub(crate) to: String,
}

/// Edge doesn't exist
#[derive(Debug, Fail, Eq, PartialEq)]
#[fail(display = "edge from '{:?}' to '{:?}' doesn't exist", from, to)]
#[error("edge from '{:?}' to '{:?}' doesn't exist", from, to)]
pub struct EdgeDoesntExist {
pub(crate) from: String,
pub(crate) to: String,
}

/// Missing node weight
#[derive(Debug, Fail, Eq, PartialEq)]
#[fail(display = "NodeWeight with index {} is missing", 0)]
#[error("NodeWeight with index {} is missing", 0)]
pub struct NodeWeightMissing(pub(crate) usize);
}

Expand Down
2 changes: 1 addition & 1 deletion cincinnati/src/plugins/catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use super::internal::openshift_secondary_metadata_parser::{
use super::internal::release_scrape_dockerv2::{
ReleaseScrapeDockerv2Plugin, ReleaseScrapeDockerv2Settings,
};
use failure::{bail, format_err, Fallible};
use commons::prelude_errors::*;
use std::fmt::Debug;

/// Key used to look up plugin-type in a configuration entry.
Expand Down
2 changes: 1 addition & 1 deletion cincinnati/src/plugins/external/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ mod tests {
use async_trait::async_trait;
use cincinnati::plugins::{interface, ExternalIO, ExternalPlugin, InternalIO, PluginResult};
use cincinnati::testing::generate_graph;
use commons::prelude_errors::*;
use commons::testing::init_runtime;
use failure::Fallible;
use log::trace;
use std::convert::TryInto;

Expand Down
6 changes: 3 additions & 3 deletions cincinnati/src/plugins/internal/cincinnati_graph_fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use self::cincinnati::plugins::prelude::*;
use self::cincinnati::plugins::prelude_plugin_impl::*;
use self::cincinnati::CONTENT_TYPE;

use commons::prelude_errors::*;
use commons::GraphError;
use failure::{Fallible, ResultExt};
use prometheus::Counter;
use reqwest;
use reqwest::header::{HeaderValue, ACCEPT};
Expand Down Expand Up @@ -158,8 +158,8 @@ mod tests {
use super::*;
use cincinnati::testing::generate_custom_graph;
use commons::metrics::{self, RegistryWrapper};
use commons::prelude_errors::*;
use commons::testing::{self, init_runtime};
use failure::{bail, Fallible};
use prometheus::Registry;

macro_rules! fetch_upstream_success_test {
Expand Down Expand Up @@ -318,7 +318,7 @@ mod tests {
let metrics_call = metrics::serve::<metrics::RegistryWrapper>(actix_web::web::Data::new(
RegistryWrapper(registry),
));
let resp = rt.block_on(metrics_call)?;
let resp = rt.block_on(metrics_call);

assert_eq!(resp.status(), 200);
if let actix_web::body::ResponseBody::Body(body) = resp.body() {
Expand Down
1 change: 0 additions & 1 deletion cincinnati/src/plugins/internal/edge_add_remove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,6 @@ mod tests {
use cincinnati::testing::generate_custom_graph;
use cincinnati::MapImpl;
use commons::testing::init_runtime;
use failure::ResultExt;

static KEY_PREFIX: &str = "test_key";

Expand Down
Loading

0 comments on commit b138286

Please sign in to comment.