diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2019-02-03 19:53:50 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2019-02-11 03:22:56 +0100 |
commit | f1a639ea8ca400db5de0864d76a8c2f374bc2bb4 (patch) | |
tree | bc0830fb6c00551b0e4e076e5c302e8438fde4e1 /bin/domain/imag-diary | |
parent | 19912f5e88bf0c0f1a1c521f6f5109ee6fac8cff (diff) |
Change id reporting API to return ExitCode
Because this API only errors when write!() errors occur, we can return
the exit code as an error here.
This way the user of the API can immediately exit if there was an IO
error, but the API automatically takes care of the right return value,
returning (exiting) with zero (0) if there was an "Broken pipe" error
and with one (1) otherwise, which is the expected behaviour here.
All calls to that API were changed accordingly.
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'bin/domain/imag-diary')
-rw-r--r-- | bin/domain/imag-diary/src/create.rs | 2 | ||||
-rw-r--r-- | bin/domain/imag-diary/src/delete.rs | 4 | ||||
-rw-r--r-- | bin/domain/imag-diary/src/list.rs | 4 | ||||
-rw-r--r-- | bin/domain/imag-diary/src/view.rs | 4 |
4 files changed, 4 insertions, 10 deletions
diff --git a/bin/domain/imag-diary/src/create.rs b/bin/domain/imag-diary/src/create.rs index 788fd33c..7e7c47b2 100644 --- a/bin/domain/imag-diary/src/create.rs +++ b/bin/domain/imag-diary/src/create.rs @@ -45,7 +45,7 @@ pub fn create(rt: &Runtime) { let mut entry = create_entry(rt.store(), &diaryname, rt); - let _ = rt.report_touched(entry.get_location()).map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(entry.get_location()).unwrap_or_exit(); let res = if rt.cli().subcommand_matches("create").unwrap().is_present("no-edit") { debug!("Not editing new diary entry"); diff --git a/bin/domain/imag-diary/src/delete.rs b/bin/domain/imag-diary/src/delete.rs index 8ce2296a..af719ca7 100644 --- a/bin/domain/imag-diary/src/delete.rs +++ b/bin/domain/imag-diary/src/delete.rs @@ -66,9 +66,7 @@ pub fn delete(rt: &Runtime) { return; } - let _ = rt - .report_touched(&to_del_location) - .map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(&to_del_location).unwrap_or_exit(); let _ = rt .store() diff --git a/bin/domain/imag-diary/src/list.rs b/bin/domain/imag-diary/src/list.rs index 7294b463..ce6d7480 100644 --- a/bin/domain/imag-diary/src/list.rs +++ b/bin/domain/imag-diary/src/list.rs @@ -55,9 +55,7 @@ pub fn list(rt: &Runtime) { .map(IntoStoreId::into_storeid) .trace_unwrap_exit(1) .for_each(|id| { - let _ = rt - .report_touched(&id) - .map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(&id).unwrap_or_exit(); writeln!(rt.stdout(), "{}", id).to_exit_code().unwrap_or_exit() }); diff --git a/bin/domain/imag-diary/src/view.rs b/bin/domain/imag-diary/src/view.rs index 5d28b412..dd1c4d66 100644 --- a/bin/domain/imag-diary/src/view.rs +++ b/bin/domain/imag-diary/src/view.rs @@ -42,9 +42,7 @@ pub fn view(rt: &Runtime) { })); let entries = entries.map(|e| { - let _ = rt - .report_touched(e.get_location()) - .map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(e.get_location()).unwrap_or_exit(); e }); |