[][src]Crate tracerr

Custom compile time captured error tracing.

Provides tools for making error output more informative. It adds ability to capture custom error trace frames (at compile time) and to display errors with the final captured trace.

Usage

The common rule:

  • Use macro to capture trace frame in the invocation place.
use tracerr::Traced;

let err = tracerr::new!("my error"); // captures frame

let res: Result<(), _> = Err(err)
    .map_err(tracerr::wrap!()); // captures frame

let err: Traced<&'static str> = res.unwrap_err();
assert_eq!(
    format!("{}\n{}", err, err.trace()),
    r"my error
error trace:
rust_out
  at src/lib.rs:6
rust_out
  at src/lib.rs:9",
);

let (val, trace) = err.into_parts();
assert_eq!(
    format!("{}\n{}", val, trace),
    r"my error
error trace:
rust_out
  at src/lib.rs:6
rust_out
  at src/lib.rs:9",
);

Macros

from_and_wrap

Provides a closure, which captures new Frame in the invocation place, applies required From implementation for the given error and wraps it into Traced wrapper containing this Frame. If the error is a Traced already then just growth its Trace with the captured Frame.

map_from_and_new

Captures new Frame in the invocation place and wraps the given error into Traced wrapper containing this Frame with applying required From implementation for the wrapped error. If the error is a Traced already then just applies From implementation and growth its Trace with the captured Frame.

map_from_and_wrap

Provides a closure, which captures new Frame in the invocation place for the given Traced wrapper and applies required From implementation for the wrapped error.

new

Captures new Frame in the invocation place and wraps the given error into Traced wrapper containing this Frame. If the error is a Traced already then just growth its Trace with the captured Frame.

new_frame

Captures and returns new Frame in the macro invocation place.

wrap

Provides a closure, which captures new Frame in the invocation place and wraps the given error into Traced wrapper containing this Frame. If the error is a Traced already then just growth its Trace with the captured Frame.

Structs

Frame

Captured frame of Trace.

Trace

Trace composed from captured Frames.

Traced

Transparent wrapper for an error which holds captured error trace along with it.

Statics

DEFAULT_FRAMES_CAPACITY

Default capacity for Trace buffer initialization.

Traits

WrapTraced

Trait for wrapping errors into a Traced wrapper and growing Trace inside.

Functions

map_from

Maps value of error wrapped in Traced with its From implementation.