Skip to main content

chik_traits/
chik_error.rs

1use thiserror::Error;
2
3#[derive(Debug, PartialEq, Eq, Clone, Error)]
4pub enum Error {
5    #[error("invalid bool encoding")]
6    InvalidBool,
7    #[error("invalid optional encoding")]
8    InvalidOptional,
9    #[error("unexpected end of buffer")]
10    EndOfBuffer,
11    #[error("invalid string encoding")]
12    InvalidString,
13    #[error("input buffer too large")]
14    InputTooLarge,
15    #[error("sequence too large")]
16    SequenceTooLarge,
17    #[error("invalid enum value")]
18    InvalidEnum,
19    #[error("invalid KLVM serialization")]
20    InvalidKlvm,
21    #[error("invalid pot iteration")]
22    InvalidPotIteration,
23    #[error("Invalid ProofOfSpace")]
24    InvalidPoS,
25    #[error("{0}")]
26    Custom(String),
27}
28
29pub type Result<T> = std::result::Result<T, Error>;
30
31#[cfg(feature = "py-bindings")]
32impl From<Error> for pyo3::PyErr {
33    fn from(err: Error) -> pyo3::PyErr {
34        pyo3::exceptions::PyValueError::new_err(err.to_string())
35    }
36}