5 releases (3 stable)

2.1.0 Jul 3, 2024
2.0.0 Jul 3, 2024
1.0.0 Jul 2, 2024
0.1.1 Jul 2, 2024
0.1.0 Jul 2, 2024

#511 in Procedural macros

Download history 356/week @ 2024-06-27 105/week @ 2024-07-04 3/week @ 2024-07-11

152 downloads per month

Custom license

18KB
323 lines

Backtrace/Backtrait Error

Procedural macros to aid the propagation of Backtraces between structs/enums (typically errors).

Dunno if it'd be useful yet.

Gist

Provides function-like procedural macros to: generate a simple trait for facilitating propagating backtraces (the trait is defined where the macro is called); and, generate an enum that contains the backtrace and optional source of the error. See below.

define_backtrace_error!(ErrorWithBacktrace); // Expands into `pub trait ErrorWithBacktrace: std::error::Error {`...

define_backtrace_source!(BacktraceSource, ErrorWithBacktrace);

Provides an attribute procedural macro to derive a simple std::error::Error implementation for structs/enums. See below.

#[backtrace_derive(ErrorWithBacktrace)]
#[derive(Debug, BacktraceError)]
struct UnitError(#[display] String, #[backtrace] BacktraceSource);

No runtime deps