Skip to content

Commit

Permalink
Merge pull request #111 from nickbabcock/anyhow
Browse files Browse the repository at this point in the history
Replace failure in examples with anyhow
  • Loading branch information
nickbabcock authored Jul 3, 2024
2 parents 532f24a + 0c8b6b8 commit 6b80f81
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ serde_test = "1.0"
criterion = "0.5"
log = { version = "0.4", features = ["serde"] }
num_cpus = "1.0"
failure = "0.1.3"
anyhow = "1.0"
libc = "0.2"
trybuild = "1.0"
doc-comment = "0.3"
Expand Down
5 changes: 2 additions & 3 deletions examples/load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use collectd_plugin::{
collectd_plugin, ConfigItem, Plugin, PluginCapabilities, PluginManager, PluginRegistration,
Value, ValueListBuilder,
};
use failure::Error;
use serde::Deserialize;
use std::error;

Expand Down Expand Up @@ -64,12 +63,12 @@ impl PluginManager for LoadManager {
/// Returns load averages (short, mid, and long term). This implementation is not as cross platform
/// as collectd's, as getloadavg is not in POSIX, but getloadavg has been in glibc since 2000 and
/// found in BSD and Solaris, so I'd wager that this should cover 99.9% of use cases.
fn get_load() -> Result<[f64; 3], Error> {
fn get_load() -> anyhow::Result<[f64; 3]> {
let mut load: [f64; 3] = [0.0; 3];

unsafe {
if libc::getloadavg(load.as_mut_ptr(), 3) != 3 {
Err(failure::err_msg("load: getloadavg failed"))
Err(anyhow::anyhow!("load: getloadavg failed"))
} else {
Ok(load)
}
Expand Down
2 changes: 1 addition & 1 deletion examples/myerror.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl Plugin for MyErrorPlugin {
if self.state.fetch_xor(true, Ordering::SeqCst) {
panic!("Oh dear what is wrong!?")
} else {
Err(failure::err_msg("bailing").into())
Err(anyhow::anyhow!("bailing").into())
}
}
}
Expand Down

0 comments on commit 6b80f81

Please sign in to comment.