Maraiah/src/durandal/err.rs

32 lines
626 B
Rust
Raw Normal View History

2018-12-11 00:08:23 -08:00
//! Error handling.
2019-02-08 21:53:27 -08:00
pub use failure::{err_msg, Error, Fail};
2018-12-11 00:08:23 -08:00
use crate::durandal::traits::PrimInt;
use std::fmt;
#[derive(PartialEq)]
pub struct ReprError<T>(pub T) where T: PrimInt;
impl<T> Fail for ReprError<T> where T: PrimInt {}
impl<T> fmt::Display for ReprError<T> where T: PrimInt
{
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result
2019-02-08 21:53:27 -08:00
{
write!(f, "representation error (got {})", self.0)
}
}
impl<T> fmt::Debug for ReprError<T> where T: PrimInt
{
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result
2019-02-08 21:53:27 -08:00
{
fmt::Display::fmt(self, f)
}
}
2018-12-11 00:08:23 -08:00
pub type ResultS<T> = Result<T, Error>;
// EOF