Merge pull request #617 from matthiasbeyer/imag-store/refactor-unwraps

Imag store/refactor unwraps
This commit is contained in:
Matthias Beyer 2016-08-03 13:56:45 +02:00 committed by GitHub
commit b6ce57418e
5 changed files with 16 additions and 25 deletions

View file

@ -36,11 +36,10 @@ pub fn create(rt: &Runtime) {
exit(1);
}
let path = build_entry_path(rt.store(), path.unwrap());
if path.is_err() {
trace_error_exit(&path.unwrap_err(), 1);
}
let path = path.unwrap();
let path = match build_entry_path(rt.store(), path.unwrap()) {
Err(e) => trace_error_exit(&e, 1),
Ok(p) => p,
};
debug!("path = {:?}", path);
if scmd.subcommand_matches("entry").is_some() {

View file

@ -10,11 +10,8 @@ pub fn delete(rt: &Runtime) {
.map(|sub| {
sub.value_of("id")
.map(|id| {
let path = build_entry_path(rt.store(), id);
if path.is_err() {
trace_error_exit(&path.unwrap_err(), 1);
}
let path = path.unwrap();
let path = try!(build_entry_path(rt.store(), id)
.map_err(|e| trace_error_exit(&e, 1)));
debug!("Deleting file at {:?}", id);
rt.store()

View file

@ -10,11 +10,10 @@ pub fn get(rt: &Runtime) {
.map(|scmd| {
scmd.value_of("id")
.map(|id| {
let path = build_entry_path(rt.store(), id);
if path.is_err() {
trace_error_exit(&path.unwrap_err(), 1);
}
let path = path.unwrap();
let path = match build_entry_path(rt.store(), id) {
Err(e) => trace_error_exit(&e, 1),
Ok(p) => p,
};
debug!("path = {:?}", path);
match rt.store().get(path) {

View file

@ -12,11 +12,8 @@ pub fn retrieve(rt: &Runtime) {
.map(|scmd| {
scmd.value_of("id")
.map(|id| {
let path = build_entry_path(rt.store(), id);
if path.is_err() {
trace_error_exit(&path.unwrap_err(), 1);
}
let path = path.unwrap();
let path = try!(build_entry_path(rt.store(), id)
.map_err(|e| trace_error_exit(&e, 1)));
debug!("path = {:?}", path);
rt.store()

View file

@ -12,11 +12,10 @@ pub fn update(rt: &Runtime) {
.map(|scmd| {
scmd.value_of("id")
.map(|id| {
let path = build_entry_path(rt.store(), id);
if path.is_err() {
trace_error_exit(&path.unwrap_err(), 1);
}
let path = path.unwrap();
let path = match build_entry_path(rt.store(), id) {
Err(e) => trace_error_exit(&e, 1),
Ok(p) => p,
};
rt.store()
.retrieve(path)