Function pretty_error_debug

Source
pub fn pretty_error_debug(error: &dyn Error, f: &mut Formatter<'_>) -> Result
Expand description

Write out the Error message and chain.

Please see the crate documentation for a more complete example.

use std::fmt::{self, Write};

pub enum MyError {
    Variant1(/* … */),
    Variant2(/* … */),
    // …
}

impl fmt::Debug for MyError {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        pretty_error_debug::pretty_error_debug(self, f)
    }
}

// TODO: implement `std::fmt::Display` and `std::error::Error`.

§Errors

Fails if writing to the f argument failed.