diff options
Diffstat (limited to 'bin/core/imag-gps/src/lib.rs')
-rw-r--r-- | bin/core/imag-gps/src/lib.rs | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/bin/core/imag-gps/src/lib.rs b/bin/core/imag-gps/src/lib.rs index 3cb2deff..594f5926 100644 --- a/bin/core/imag-gps/src/lib.rs +++ b/bin/core/imag-gps/src/lib.rs @@ -36,7 +36,7 @@ extern crate clap; #[macro_use] extern crate log; -#[macro_use] extern crate failure; +#[macro_use] extern crate anyhow; extern crate libimagentrygps; extern crate libimagrt; @@ -47,9 +47,9 @@ extern crate libimagstore; use std::io::Write; use std::str::FromStr; -use failure::Error; -use failure::Fallible as Result; -use failure::err_msg; +use anyhow::Error; +use anyhow::Result; + use clap::App; use libimagstore::storeid::StoreId; @@ -67,7 +67,7 @@ mod ui; pub enum ImagGps {} impl ImagApplication for ImagGps { fn run(rt: Runtime) -> Result<()> { - match rt.cli().subcommand_name().ok_or_else(|| err_msg("No subcommand called"))? { + match rt.cli().subcommand_name().ok_or_else(|| anyhow!("No subcommand called"))? { "add" => add(&rt), "remove" => remove(&rt), "get" => get(&rt), @@ -79,7 +79,7 @@ impl ImagApplication for ImagGps { { Ok(()) } else { - Err(format_err!("Subcommand failed")) + Err(anyhow!("Subcommand failed")) } } } @@ -105,7 +105,7 @@ impl ImagApplication for ImagGps { fn rt_get_ids(rt: &Runtime) -> Result<Vec<StoreId>> { rt .ids::<crate::ui::PathProvider>()? - .ok_or_else(|| err_msg("No ids supplied")) + .ok_or_else(|| anyhow!("No ids supplied")) } fn add(rt: &Runtime) -> Result<()> { @@ -115,11 +115,11 @@ fn add(rt: &Runtime) -> Result<()> { let ary = value.split('.') .map(|v| {debug!("Parsing = {}", v); v}) .map(FromStr::from_str) - .map(|elem| elem.or_else(|_| Err(err_msg("Error while converting number")))) + .map(|elem| elem.or_else(|_| Err(anyhow!("Error while converting number")))) .collect::<Result<Vec<i64>>>()?; - let degree = ary.get(0).ok_or_else(|| err_msg("Degree missing. This value is required."))?; - let minute = ary.get(1).ok_or_else(|| err_msg("Degree missing. This value is required."))?; + let degree = ary.get(0).ok_or_else(|| anyhow!("Degree missing. This value is required."))?; + let minute = ary.get(1).ok_or_else(|| anyhow!("Degree missing. This value is required."))?; let second = ary.get(2).unwrap_or(&0); Ok((*degree, *minute, *second)) @@ -141,7 +141,7 @@ fn add(rt: &Runtime) -> Result<()> { .map(|id| { rt.store() .get(id.clone())? - .ok_or_else(|| format_err!("No such entry: {}", id))? + .ok_or_else(|| anyhow!("No such entry: {}", id))? .set_coordinates(c.clone())?; rt.report_touched(&id) @@ -162,9 +162,9 @@ fn remove(rt: &Runtime) -> Result<()> { let removed_value : Coordinates = rt .store() .get(id.clone())? - .ok_or_else(|| format_err!("No such entry: {}", id))? + .ok_or_else(|| anyhow!("No such entry: {}", id))? .remove_coordinates()? - .ok_or_else(|| format_err!("Entry had no coordinates: {}", id))??; + .ok_or_else(|| anyhow!("Entry had no coordinates: {}", id))??; if print_removed { writeln!(rt.stdout(), "{}", removed_value)?; @@ -185,11 +185,11 @@ fn get(rt: &Runtime) -> Result<()> { .store() .get(id.clone())? .ok_or_else(|| { // if we have Ok(None) - format_err!("No such entry: {}", id) + anyhow!("No such entry: {}", id) })? .get_coordinates()? .ok_or_else(|| { // if we have Ok(None) - format_err!("Entry has no coordinates: {}", id) + anyhow!("Entry has no coordinates: {}", id) })?; writeln!(stdout, "{}", value)?; |