From f1e7b40cc5e50bf50bdc61f1f9ca67b1841fab7a Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 15 Jul 2016 21:34:45 +0200 Subject: [PATCH] Add utility for calling trace_error() and exit() --- libimagerror/src/trace.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libimagerror/src/trace.rs b/libimagerror/src/trace.rs index e04b292f..ccba6806 100644 --- a/libimagerror/src/trace.rs +++ b/libimagerror/src/trace.rs @@ -26,6 +26,15 @@ pub fn trace_error(e: &Error) { write!(stderr(), "\n").ok(); } +/// Convenience function: calls `trace_error()` with `e` and afterwards `std::process::exit()` +/// with `code` +pub fn trace_error_exit(e: &Error, code: i32) { + use std::process::exit; + + trace_error(e); + exit(code); +} + /// Print an Error type and its cause recursively, but only `max` levels /// /// Output is the same as for `trace_error()`, though there are only `max` levels printed.