Skip to content

Commit b138286

Browse files
committed
Replace failure crate with anyhow+thiserror
Failure was [deprecated][0] and suggests anyhow+thiserror to replace itself in dependent projects. [0]: rust-lang-deprecated/failure#347
1 parent f70fd56 commit b138286

File tree

52 files changed

+211
-207
lines changed

Some content is hidden

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

52 files changed

+211
-207
lines changed

Cargo.lock

Lines changed: 43 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cincinnati/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ commons = { path = "../commons" }
1010
custom_debug_derive = "^0.1.7"
1111
daggy = { version = "^0.6.0", features = [ "serde-1" ] }
1212
env_logger = "^0.6.0"
13-
failure = "^0.1.1"
1413
futures = "0.3"
1514
futures-locks = "0.5.0"
1615
lazy_static = "^1.2.0"

cincinnati/src/lib.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,15 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#[macro_use]
16-
extern crate failure;
17-
1815
#[macro_use]
1916
extern crate serde_derive;
2017

2118
#[macro_use]
2219
pub mod plugins;
2320

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

155152
/// Errors that can be returned by the methods in this library
156153
pub mod errors {
154+
use commons::prelude_errors::*;
155+
157156
/// Edge already exists
158157
#[derive(Debug, Fail, Eq, PartialEq)]
159-
#[fail(display = "edge from {:?} to {:?} already exists", from, to)]
158+
#[error("edge from {:?} to {:?} already exists", from, to)]
160159
pub struct EdgeAlreadyExists {
161160
pub(crate) from: String,
162161
pub(crate) to: String,
163162
}
164163

165164
/// Edge doesn't exist
166165
#[derive(Debug, Fail, Eq, PartialEq)]
167-
#[fail(display = "edge from '{:?}' to '{:?}' doesn't exist", from, to)]
166+
#[error("edge from '{:?}' to '{:?}' doesn't exist", from, to)]
168167
pub struct EdgeDoesntExist {
169168
pub(crate) from: String,
170169
pub(crate) to: String,
171170
}
172171

173172
/// Missing node weight
174173
#[derive(Debug, Fail, Eq, PartialEq)]
175-
#[fail(display = "NodeWeight with index {} is missing", 0)]
174+
#[error("NodeWeight with index {} is missing", 0)]
176175
pub struct NodeWeightMissing(pub(crate) usize);
177176
}
178177

cincinnati/src/plugins/catalog.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use super::internal::openshift_secondary_metadata_parser::{
2222
use super::internal::release_scrape_dockerv2::{
2323
ReleaseScrapeDockerv2Plugin, ReleaseScrapeDockerv2Settings,
2424
};
25-
use failure::{bail, format_err, Fallible};
25+
use commons::prelude_errors::*;
2626
use std::fmt::Debug;
2727

2828
/// Key used to look up plugin-type in a configuration entry.

cincinnati/src/plugins/external/web.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ mod tests {
2020
use async_trait::async_trait;
2121
use cincinnati::plugins::{interface, ExternalIO, ExternalPlugin, InternalIO, PluginResult};
2222
use cincinnati::testing::generate_graph;
23+
use commons::prelude_errors::*;
2324
use commons::testing::init_runtime;
24-
use failure::Fallible;
2525
use log::trace;
2626
use std::convert::TryInto;
2727

cincinnati/src/plugins/internal/cincinnati_graph_fetch.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ use self::cincinnati::plugins::prelude::*;
99
use self::cincinnati::plugins::prelude_plugin_impl::*;
1010
use self::cincinnati::CONTENT_TYPE;
1111

12+
use commons::prelude_errors::*;
1213
use commons::GraphError;
13-
use failure::{Fallible, ResultExt};
1414
use prometheus::Counter;
1515
use reqwest;
1616
use reqwest::header::{HeaderValue, ACCEPT};
@@ -158,8 +158,8 @@ mod tests {
158158
use super::*;
159159
use cincinnati::testing::generate_custom_graph;
160160
use commons::metrics::{self, RegistryWrapper};
161+
use commons::prelude_errors::*;
161162
use commons::testing::{self, init_runtime};
162-
use failure::{bail, Fallible};
163163
use prometheus::Registry;
164164

165165
macro_rules! fetch_upstream_success_test {
@@ -318,7 +318,7 @@ mod tests {
318318
let metrics_call = metrics::serve::<metrics::RegistryWrapper>(actix_web::web::Data::new(
319319
RegistryWrapper(registry),
320320
));
321-
let resp = rt.block_on(metrics_call)?;
321+
let resp = rt.block_on(metrics_call);
322322

323323
assert_eq!(resp.status(), 200);
324324
if let actix_web::body::ResponseBody::Body(body) = resp.body() {

cincinnati/src/plugins/internal/edge_add_remove.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,6 @@ mod tests {
333333
use cincinnati::testing::generate_custom_graph;
334334
use cincinnati::MapImpl;
335335
use commons::testing::init_runtime;
336-
use failure::ResultExt;
337336

338337
static KEY_PREFIX: &str = "test_key";
339338

0 commit comments

Comments
 (0)