Crates.io | pretty_panics |
lib.rs | pretty_panics |
version | 0.1.0 |
source | src |
created_at | 2024-08-23 08:58:46.215656 |
updated_at | 2024-08-23 08:58:46.215656 |
description | pretty panic messages |
homepage | https://github.com/bizarre/pretty_panic |
repository | |
max_upload_size | |
id | 1348894 |
size | 8,398 |
pretty_panics
is a crate that provides an easy way to customize panic messages and error messages.
If use-default-features
is enabled, pretty_panics
will provide default formatters for panics and errors.
use pretty_panics::pretty_panic;
#[pretty_panic]
fn main() -> std::result::Result<(), SomeDisplayError> {
...
}
use pretty_panics::pretty_panic;
use thiserror::Error;
#[derive(Error, Debug)]
enum SimpleError {
#[error("an error")]
AnError
}
fn error_formatter(error: &SimpleError) -> String {
format!("uhhh something broke guys... {error}")
}
#[pretty_panic(formatter = error_formatter)]
fn main() -> anyhow::Result<(), SimpleError> {
Result::<(), SimpleError>::Err(SimpleError::AnError)?;
Ok(())
}
caveats: caveats: