1 unstable release

0.2.0 Mar 16, 2022

#75 in #backtrace

Download history 88/week @ 2024-11-16 9/week @ 2024-11-23 195/week @ 2024-11-30 94/week @ 2024-12-07 12/week @ 2024-12-14 2/week @ 2024-12-21 27/week @ 2024-12-28 81/week @ 2025-01-04 91/week @ 2025-01-11 58/week @ 2025-01-18 75/week @ 2025-01-25 42/week @ 2025-02-01 123/week @ 2025-02-08 297/week @ 2025-02-15 141/week @ 2025-02-22 103/week @ 2025-03-01

666 downloads per month

MIT/Apache

11KB
142 lines

Backtrace error submission crate

Installation

[dependencies]
backtraceio = "0.1"

Usage

Global error handler

Pass your custom token and upload url from your Backtrace account and a report modification closure/function to the backtraceio::register_error_handler function.

backtraceio::register_error_handler(
    "https://UNIVERSE.sp.backtrace.io:6098",
    "YOURTOKEN",
    closure
);

Report modification function

The error handler will pass the Report and std::panic::PanicInfo objects back to the user, in case there are additional attributes/annotations to be defined (described more in detail here). It should accept &mut Report, &PanicInfo, making any changes desired to the report.

Example

use backtraceio::Report;

fn main() {
    backtraceio::register_error_handler(
        "https://UNIVERSE.sp.backtrace.io:6098",
        "YOUR_TOKEN",
        |r: &mut Report, _| {
            let cpus = num_cpus::get();
            let cpus = cpus.to_string();
            r.attributes.insert(String::from("cpu.cores"), cpus);
        },
    );

    println!("Hello, world!");
    panic!("{:?}", 69);
}

Dependencies

~7–19MB
~282K SLoC