use std::fmt::{Debug, Display, Formatter};
pub struct Error {
inner: crate::platform::Error,
}
impl From<crate::platform::Error> for Error {
fn from(inner: crate::platform::Error) -> Error {
Error { inner }
}
}
impl Debug for Error {
#[inline]
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
Debug::fmt(&self.inner, f)
}
}
impl Display for Error {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
Display::fmt(&self.inner, f)
}
}
impl std::error::Error for Error {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
self.inner.source()
}
}
impl From<HandlerError> for Error {
fn from(e: HandlerError) -> Self {
Self { inner: crate::platform::Error::Handler(e) }
}
}
pub struct HandlerError {
inner: Box<dyn std::error::Error>,
}
impl HandlerError {
#[inline]
pub fn from_boxed(error: Box<dyn std::error::Error>) -> Self {
Self { inner: error }
}
#[inline]
pub fn source(&self) -> &(dyn std::error::Error + 'static) {
self.inner.as_ref()
}
#[inline]
pub fn into_inner(self) -> Box<dyn std::error::Error> {
self.inner
}
}
impl Debug for HandlerError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
Debug::fmt(&self.inner, f)
}
}
impl Display for HandlerError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
Display::fmt(&self.inner, f)
}
}
impl<E: std::error::Error + 'static> From<E> for HandlerError {
fn from(value: E) -> Self {
Self { inner: Box::new(value) }
}
}
impl From<HandlerError> for Box<dyn std::error::Error + 'static> {
fn from(value: HandlerError) -> Self {
value.inner
}
}