pytorch_reader/nested/
error.rs1#[derive(thiserror::Error, Debug)]
3pub enum Error {
4 #[error("failed to deserialize: {0}")]
6 Deserialize(#[from] serde::de::value::Error),
7
8 #[error("failed to serialize")]
10 Serialize(String),
11
12 #[error("invalid state")]
14 InvalidState,
15
16 #[error("other error: {0}")]
18 Other(String),
19}
20
21impl serde::de::Error for Error {
22 fn custom<T: std::fmt::Display>(msg: T) -> Self {
23 Error::Deserialize(serde::de::value::Error::custom(msg.to_string()))
24 }
25}
26
27impl serde::ser::Error for Error {
28 fn custom<T: std::fmt::Display>(msg: T) -> Self {
29 Error::Serialize(msg.to_string())
30 }
31}