Skip to content
This repository has been archived by the owner on Oct 26, 2023. It is now read-only.
/ ebacktrace-rust Public archive

A simple error wrapper which captures a backtrace and can carry an optional textual description

Notifications You must be signed in to change notification settings

KizzyCode/ebacktrace-rust

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

License BSD-2-Clause License MIT AppVeyor CI docs.rs crates.io Download numbers dependency status

ebacktrace

Welcome to ebacktrace 🎉

This crate implements a simple error wrapper which captures a backtrace upon creation and can carry an optional textual description of the error.

Example

use ebacktrace::define_error;
use std::fmt::{ self, Display, Formatter };

/// The error kind
#[derive(Debug, Copy, Clone)]
enum ErrorKind {
    MyErrorA,
    Testolope
}
impl Display for ErrorKind {
    fn fmt(&self, f: &mut Formatter) -> fmt::Result {
        write!(f, "{:#?}", self)
    }
}
// Define our custom error type
define_error!(Error);

/// A function that will always fail
fn will_fail() -> Result<(), Error<ErrorKind>> {
    Err(ErrorKind::Testolope)?
}

// Will panic with a nice error
if let Err(e) = will_fail() {
    eprintln!("Error: {:?}", e);
    panic!("Fatal error")
}

Features

This crate currently has one feature gate:

  • force_backtrace (disabled by default): If force_backtrace is enable, the backtrace is always captured, regardless whether RUST_BACKTRACE is set or not.

About

A simple error wrapper which captures a backtrace and can carry an optional textual description

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages