32 lines
626 B
Rust
32 lines
626 B
Rust
//! Error handling.
|
|
|
|
pub use failure::{err_msg, Error, Fail};
|
|
|
|
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)
|
|
}
|
|
}
|
|
|
|
pub type ResultS<T> = Result<T, Error>;
|
|
|
|
// EOF
|