chik_traits/
chik_error.rs1use 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("{0}")]
22 Custom(String),
23}
24
25pub type Result<T> = std::result::Result<T, Error>;
26
27#[cfg(feature = "py-bindings")]
28impl From<Error> for pyo3::PyErr {
29 fn from(err: Error) -> pyo3::PyErr {
30 pyo3::exceptions::PyValueError::new_err(err.to_string())
31 }
32}