pub type Result<T = ()> = std::result::Result<T, crate::Error>;
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("Async error: {0}")]
Async(libpq::errors::Error),
#[cfg(feature = "chrono")]
#[error("{0}")]
Chrono(String),
#[cfg(feature = "config")]
#[error(transparent)]
Config(#[from] config::ConfigError),
#[error("{error}")]
Connect {
dsn: String,
error: libpq::errors::Error,
},
#[error("Copy error: {0}")]
Copy(libpq::errors::Error),
#[error("Unable to escape '{0}': {1}")]
Escape(String, libpq::errors::Error),
#[error("Unable to convert from SQL {} (oid={}) to {rust_type}: {value}. Try {}", pg_type.name, pg_type.oid, crate::pq::sql_to_rust(pg_type))]
FromSql {
pg_type: crate::pq::Type,
rust_type: String,
value: String,
},
#[error("{0}")]
Infallible(#[from] std::convert::Infallible),
#[error("{0}")]
Inspect(String),
#[error(transparent)]
Io(#[from] std::io::Error),
#[cfg(feature = "jiff")]
#[error("{0}")]
Jiff(#[from] jiff::Error),
#[error("{0}")]
Libpq(#[from] libpq::errors::Error),
#[error("Missing field {0}")]
MissingField(String),
#[error("Mutex error: {0}")]
Mutex(String),
#[error("Try to retreive null field as non-option type")]
NotNull,
#[error("{0}")]
Parse(String),
#[error(transparent)]
ParseBoolError(#[from] std::str::ParseBoolError),
#[error(transparent)]
ParseIntError(#[from] std::num::ParseIntError),
#[error("Ping error: {0:?}")]
Ping(crate::connection::PingStatus),
#[error("Invalid primary key")]
PrimaryKey,
#[error("{}", .0.error_message().unwrap().unwrap_or_else(|| "Unknow SQL error".to_string()))]
Sql(crate::pq::Result),
#[error("Invalid convertion from {} to {rust_type}: {message}", .pg_type.name)]
ToSql {
pg_type: crate::pq::Type,
rust_type: String,
message: String,
},
#[error(transparent)]
TryFromIntError(#[from] std::num::TryFromIntError),
#[error(transparent)]
Utf8(#[from] std::string::FromUtf8Error),
#[cfg(feature = "xml")]
#[error(transparent)]
Xml(#[from] xmltree::Error),
}