Skip to content

Commit

Permalink
Implement std::Error for HWI's errors
Browse files Browse the repository at this point in the history
  • Loading branch information
danielabrozzoni committed Sep 22, 2022
1 parent 94fb6c7 commit ab07d13
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::fmt;

#[derive(Debug, PartialEq, Eq, Clone)]
pub enum Error {
JSON(String),
Expand All @@ -22,3 +24,11 @@ impl_error!(serde_json::Error, JSON);
impl_error!(std::str::Utf8Error, Utf8);
impl_error!(std::io::Error, IOError);
impl_error!(pyo3::prelude::PyErr, PyErr);

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

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

0 comments on commit ab07d13

Please sign in to comment.