#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error(transparent)]
Extern(Box<dyn std::error::Error + Send + Sync>),
#[error("Tried to serialize a {0} at the top level. Only key-value shapes are supported at the top level of a query parameter.")]
UnsupportedAtTopLevel(&'static str),
#[error("Tried to serialize a {0} in place of a value. Only simple values are supported on the right-hand side of a parameter.")]
UnsupportedNestedStruct(&'static str),
#[error("{0}")]
Custom(String),
}
pub type Result<T, E = Error> = std::result::Result<T, E>;
impl From<std::io::Error> for Error {
fn from(err: std::io::Error) -> Self {
Error::Extern(Box::new(err))
}
}
impl From<std::string::FromUtf8Error> for Error {
fn from(err: std::string::FromUtf8Error) -> Self {
Error::Extern(Box::new(err))
}
}
impl serde::ser::Error for Error {
fn custom<T>(msg: T) -> Self
where
T: std::fmt::Display,
{
Error::Custom(msg.to_string())
}
}