Skip to content

Commit

Permalink
Implement Display and Error for EvalErr (Chia-Network#334)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rigidity authored and MarvinQuevedo committed Aug 26, 2023
1 parent d9c7a94 commit 41c02a2
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/reduction.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::io;
use std::{fmt, io};

use crate::allocator::NodePtr;
use crate::cost::Cost;
Expand All @@ -11,6 +11,14 @@ pub struct Reduction(pub Cost, pub NodePtr);

pub type Response = Result<Reduction, EvalErr>;

impl fmt::Display for EvalErr {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Error at {:?}: {}", self.0, self.1)
}
}

impl std::error::Error for EvalErr {}

impl From<EvalErr> for io::Error {
fn from(v: EvalErr) -> Self {
Self::new(io::ErrorKind::Other, v.1)
Expand Down

0 comments on commit 41c02a2

Please sign in to comment.