| Crates.io | ebacktrace |
| lib.rs | ebacktrace |
| version | 0.5.1 |
| created_at | 2021-06-29 16:39:07.210682+00 |
| updated_at | 2022-03-01 18:11:36.782748+00 |
| description | A simple error wrapper which captures a backtrace and can carry an optional textual description |
| homepage | |
| repository | https://github.com/KizzyCode/ebacktrace-rust |
| max_upload_size | |
| id | 416229 |
| size | 19,539 |
ebacktraceWelcome 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.
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")
}
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.