cgp-error-std 0.5.0-beta2

Context-generic programming error handlers implemented using `std::error::Error`
Documentation
use alloc::string::String;
use core::error::Error as StdError;
use core::fmt::{Debug, Display};

use crate::Error;

pub struct WrapError {
    pub detail: String,
    pub source: Error,
}

impl Display for WrapError {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        write!(f, "{}: {}", self.detail, self.source)
    }
}

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

impl StdError for WrapError {
    fn source(&self) -> Option<&(dyn StdError + 'static)> {
        Some(self.source.as_ref())
    }
}