rust-sen/sehn-serde/src/de/error.rs

32 lines
644 B
Rust

use error_chain::{
error_chain,
error_chain_processing,
impl_error_chain_processed,
impl_error_chain_kind,
impl_extract_backtrace
};
error_chain! {
errors {
Eof {
description("unexpected end of input")
}
NestingLimit {
description("nesting limit reached")
}
Unexpected(c: char) {
description("unexpected character")
display("unexpected character: '{}'", c)
}
Message(t: String) {
description(t)
display("internal error: '{}'", t)
}
}
}
impl serde::de::Error for Error {
fn custom<T: std::fmt::Display>(msg: T) -> Self {
ErrorKind::Message(msg.to_string()).into()
}
}