Maraiah/src/durandal/err.rs

28 lines
610 B
Rust
Raw Normal View History

2018-12-11 00:08:23 -08:00
//! Error handling.
2019-02-05 23:01:47 -08:00
pub use failure::{Error, Fail, err_msg};
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
{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
{fmt::Display::fmt(self, f)}
}
2018-12-11 00:08:23 -08:00
pub type ResultS<T> = Result<T, Error>;
// EOF