pub use std::error::Error as ErrorAdapter;
#[ macro_export ]
macro_rules! err
{
( $msg : expr ) =>
{
$crate::Error::new( $msg )
};
( $msg : expr, $( $arg : expr ),+ ) =>
{
$crate::Error::new( format!( $msg, $( $arg ),+ ) )
};
}
#[ derive( core::fmt::Debug, core::clone::Clone, core::cmp::PartialEq ) ]
pub struct Error
{
msg : String,
}
impl Error
{
pub fn new< Msg : Into< String > >( msg : Msg ) -> Error
{
Error { msg : msg.into() }
}
pub fn msg( &self ) -> &String
{
&self.msg
}
}
impl core::fmt::Display for Error
{
fn fmt(&self, f: &mut core::fmt::Formatter< '_ >) -> core::fmt::Result
{
write!( f, "{}", self.msg )
}
}
impl std::error::Error for Error
{
fn description( &self ) -> &str
{
&self.msg
}
}