#helper #macro #miette #error-handling

miette_helper

Crate providing helper macros for miette

1 unstable release

0.1.0 Oct 25, 2022

#2993 in Rust patterns

MIT/Apache

6KB

Miette Helper

A library providing helper macros for Miette as well as some general error-handling helper macros

I recommend to use it in conjuntion with unwrap or

Provided Functions

wrap_err

Converts given Result into Diagnostic and returns it. Made for applications not using a custom error enum/struct.

let a: Result<u32, std::io::Error> = Ok(42);
let b: u32 = wrap_err!(a, "Failed to calulate number")? + 27;

or_wrap_err

Converts given Option into Diagnostic with the given error message.

let b: Option<&str> = None;
let c: &str = or_wrap_err!(b, "No path specified")?

lib.rs:

Miette Helper

Simple crate providing helper macros for miette in libraries.

You will get "random" compiler errors, since I decided against checking the type to ensure compatibility with type aliases. please make sure the error isn't mentioned in the macro doc before reporting.

No runtime deps