config/ser/error.rs
1use thiserror::Error;
2
3/// Represents the serialization errors that can occur.
4#[derive(Error, Debug)]
5pub enum Error {
6 /// A custom error message from serde.
7 #[error("{0}")]
8 Custom(String),
9
10 /// A map key could not be serialized to a string.
11 #[error("map keys must be serializable to strings")]
12 NonStringKey,
13}
14
15#[cfg(feature = "typed")]
16impl serde::ser::Error for Error {
17 #[inline]
18 fn custom<T: std::fmt::Display>(msg: T) -> Self {
19 Self::Custom(msg.to_string())
20 }
21}