#error #backtrace

error-backtrace

Simple crate to backtrace your errors

6 releases (3 breaking)

0.3.1 Aug 28, 2024
0.3.0 Aug 28, 2024
0.2.1 Aug 28, 2024
0.1.0 Aug 23, 2024
0.0.1 Aug 23, 2024

#725 in Debugging

Download history 622/week @ 2024-08-23 73/week @ 2024-08-30 12/week @ 2024-09-13 19/week @ 2024-09-20 6/week @ 2024-09-27 1/week @ 2024-10-04

187 downloads per month

MIT license

6KB
102 lines

Error Backtrace

This is a simple crate to debug where your errors are comming from. With the smallest possiable amount of code.

Usage

  1. cargo add error-backtrace
  2. Add use error_backtrace::{Result, ResultBacktrace}; where you use Result and .backtrace() to backtrace them
  3. And add .into() where the error is created. (Compiler will help you with this)
  4. Where you read errors use error.inner or *error

Example:

use error_backtrace::{Result, ResultBacktrace};

#[derive(Debug)]
struct Error;

fn main() -> Result<(), Error> {
    maybe_error().backtrace()?;
    Ok(())
}

fn maybe_error() -> Result<(), Error> {
    error_source()?;
    Ok(())
}

fn error_source() -> Result<(), Error> {
    Err(Error {}.into())
}

Dependencies

~0–5MB
~10K SLoC