diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2016-02-09 20:16:21 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2016-02-11 15:48:41 +0100 |
commit | 0a8eaa14116041dcd00e1474c1baed42e2530c68 (patch) | |
tree | 005c2c985d3ded92c7e70d39f300f4a593283161 /libimagutil | |
parent | d8ae741f31af2ac719bd089c249a034486ef242a (diff) |
Add documentation of functions
Diffstat (limited to 'libimagutil')
-rw-r--r-- | libimagutil/src/trace.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/libimagutil/src/trace.rs b/libimagutil/src/trace.rs index af949e7f..cdb65aa5 100644 --- a/libimagutil/src/trace.rs +++ b/libimagutil/src/trace.rs @@ -2,11 +2,31 @@ use std::error::Error; use std::io::Write; use std::io::stderr; +/// Print an Error type and its cause recursively +/// +/// The error is printed with "Error NNNN :" as prefix, where "NNNN" is a number which increases +/// which each recursion into the errors cause. The error description is used to visualize what +/// failed and if there is a cause "-- caused by:" is appended, and the cause is printed on the next +/// line. +/// +/// Example output: +/// +/// ```ignore +/// Error 1 : Some error -- caused by: +/// Error 2 : Some other error -- caused by: +/// Error 3 : Yet another Error -- caused by: +/// ... +/// +/// Error <NNNN> : <Error description> +/// ``` pub fn trace_error(e: &Error) { print_trace_maxdepth(count_error_causes(e), e, ::std::u64::MAX); write!(stderr(), ""); } +/// 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. pub fn trace_error_maxdepth(e: &Error, max: u64) { let n = count_error_causes(e); write!(stderr(), "{}/{} Levels of errors will be printed", (if max > n { n } else { max }), n); @@ -14,6 +34,9 @@ pub fn trace_error_maxdepth(e: &Error, max: u64) { write!(stderr(), ""); } +/// Print an Error type and its cause recursively with the debug!() macro +/// +/// Output is the same as for `trace_error()`. pub fn trace_error_dbg(e: &Error) { print_trace_dbg(0, e); } |