Crate tracerr

Source
Expand description

§tracerr

crates.io Rust 1.75+ Unsafe Forbidden
CI Rust docs

API Docs | Changelog

Custom compile-time captured error tracing for Rust.

§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:7
rust_out
  at src/lib.rs:10",
);

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

§License

Copyright © 2019-2025 Instrumentisto Team, https://github.com/instrumentisto

This software is subject to the terms of the Blue Oak Model License 1.0.0. If a copy of the BlueOak-1.0.0 license was not distributed with this file, You can obtain one at https://blueoakcouncil.org/license/1.0.0.

Macros§

from_and_wrap
Provides a closure, which captures a new Frame in the invocation place, applies the required From conversion for the given error, and wraps it into a Traced wrapper with this Frame.
map_from_and_new
Captures a new Frame in the invocation place and wraps the given error into a Traced wrapper containing this Frame with applying the required From conversion for the wrapped error.
map_from_and_wrap
Provides a closure, which captures a new Frame in the invocation place for the given Traced wrapper and applies the required From conversion for the wrapped error.
new
Captures a new Frame in the invocation place and wraps the given error into a Traced wrapper containing this Frame.
new_frame
Captures and returns new Frame in the macro invocation place.
wrap
Provides a closure, which captures a new Frame in the invocation place and wraps the given error into a Traced wrapper containing this Frame.

Structs§

Frame
Captured frame of Trace.
Trace
Trace composed from captured Frames.
Traced
Wrapper for an arbitrary error holding the captured error trace along.

Statics§

DEFAULT_FRAMES_CAPACITY
Default capacity for a Trace buffer initialization.

Traits§

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

Functions§

map_from
Maps an inner value of an error wrapped in a Traced with its From implementation.