summaryrefslogtreecommitdiff
path: root/bin/core/imag-store
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2018-10-30 18:40:52 +0100
committerMatthias Beyer <mail@beyermatthias.de>2018-10-30 18:46:29 +0100
commite3911d97d945ec72c696505c8e40207f67916b9e (patch)
tree690780566b6d696b0a6936b4947484e3a4afc9c7 /bin/core/imag-store
parent3272dbfd74f70cc38aef13583dc3d737f0afb013 (diff)
downloadimag-e3911d97d945ec72c696505c8e40207f67916b9e.zip
imag-e3911d97d945ec72c696505c8e40207f67916b9e.tar.gz
imag-store: Move from error-chain to failure
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'bin/core/imag-store')
-rw-r--r--bin/core/imag-store/Cargo.toml2
-rw-r--r--bin/core/imag-store/src/create.rs18
-rw-r--r--bin/core/imag-store/src/error.rs38
-rw-r--r--bin/core/imag-store/src/main.rs3
4 files changed, 6 insertions, 55 deletions
diff --git a/bin/core/imag-store/Cargo.toml b/bin/core/imag-store/Cargo.toml
index 9bc96a4..63731f5 100644
--- a/bin/core/imag-store/Cargo.toml
+++ b/bin/core/imag-store/Cargo.toml
@@ -24,7 +24,7 @@ maintenance = { status = "actively-developed" }
[dependencies]
log = "0.4.0"
toml = "0.4"
-error-chain = "0.12"
+failure = "0.1"
libimagstore = { version = "0.9.0", path = "../../../lib/core/libimagstore", features = ["verify"] }
libimagrt = { version = "0.9.0", path = "../../../lib/core/libimagrt" }
diff --git a/bin/core/imag-store/src/create.rs b/bin/core/imag-store/src/create.rs
index f7365b8..6ee5ecf 100644
--- a/bin/core/imag-store/src/create.rs
+++ b/bin/core/imag-store/src/create.rs
@@ -20,12 +20,13 @@
use std::path::PathBuf;
use std::io::stdin;
use std::fs::OpenOptions;
-use std::result::Result as RResult;
use std::io::Read;
use std::ops::DerefMut;
use clap::ArgMatches;
use toml::Value;
+use failure::Fallible as Result;
+use failure::err_msg;
use libimagrt::runtime::Runtime;
use libimagstore::store::Entry;
@@ -33,13 +34,8 @@ use libimagstore::storeid::StoreId;
use libimagerror::trace::MapErrTrace;
use libimagutil::debug_result::*;
-use error::StoreError;
-use error::StoreErrorKind;
-use error::ResultExt;
use util::build_toml_header;
-type Result<T> = RResult<T, StoreError>;
-
pub fn create(rt: &Runtime) {
let scmd = rt.cli().subcommand_matches("create").unwrap();
debug!("Found 'create' subcommand...");
@@ -95,13 +91,9 @@ fn create_from_cli_spec(rt: &Runtime, matches: &ArgMatches, path: &StoreId) -> R
fn create_from_source(rt: &Runtime, matches: &ArgMatches, path: &StoreId) -> Result<()> {
let content = matches
.value_of("from-raw")
- .ok_or(StoreError::from_kind(StoreErrorKind::NoCommandlineCall))
- .map(string_from_raw_src);
+ .ok_or_else(|| err_msg("No Commandline call"))
+ .map(string_from_raw_src)?;
- if content.is_err() {
- return content.map(|_| ());
- }
- let content = content.unwrap();
debug!("Content with len = {}", content.len());
Entry::from_str(path.clone(), &content[..])
@@ -118,7 +110,6 @@ fn create_from_source(rt: &Runtime, matches: &ArgMatches, path: &StoreId) -> Res
r
})
.map_dbg_err(|e| format!("Error storing entry: {:?}", e))
- .chain_err(|| StoreErrorKind::BackendError)
}
fn create_with_content_and_header(rt: &Runtime,
@@ -142,7 +133,6 @@ fn create_with_content_and_header(rt: &Runtime,
debug!("New header set");
}
})
- .chain_err(|| StoreErrorKind::BackendError)
}
fn string_from_raw_src(raw_src: &str) -> String {
diff --git a/bin/core/imag-store/src/error.rs b/bin/core/imag-store/src/error.rs
deleted file mode 100644
index be51775..0000000
--- a/bin/core/imag-store/src/error.rs
+++ /dev/null
@@ -1,38 +0,0 @@
-//
-// imag - the personal information management suite for the commandline
-// Copyright (C) 2015-2018 Matthias Beyer <mail@beyermatthias.de> and contributors
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; version
-// 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-//
-
-error_chain! {
- types {
- StoreError, StoreErrorKind, ResultExt, Result;
- }
-
- errors {
- BackendError {
- description("Backend Error")
- display("Backend Error")
- }
-
- NoCommandlineCall {
- description("No commandline call")
- display("No commandline call")
- }
-
- }
-}
-
diff --git a/bin/core/imag-store/src/main.rs b/bin/core/imag-store/src/main.rs
index 6a90796..5328c3a 100644
--- a/bin/core/imag-store/src/main.rs
+++ b/bin/core/imag-store/src/main.rs
@@ -36,7 +36,7 @@ extern crate clap;
#[macro_use] extern crate log;
extern crate toml;
#[cfg(test)] extern crate toml_query;
-#[macro_use] extern crate error_chain;
+extern crate failure;
#[macro_use] extern crate libimagrt;
extern crate libimagstore;
@@ -54,7 +54,6 @@ use libimagerror::trace::MapErrTrace;
mod create;
mod delete;
-mod error;
mod get;
mod retrieve;
mod ui;