use std::io;
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum Error {
#[error("{context}: {message} (code {code})")]
Sqlite {
context: String,
code: i32,
message: String,
},
#[error("WAL frame {frame} conflicts with the frame already in the replica")]
Conflict { frame: u32 },
#[error("not a SQLite database: {0}")]
NotADatabase(String),
#[error("invalid database name {0:?}")]
InvalidName(String),
#[error("{0} contains a NUL byte")]
Nul(&'static str),
#[error("peer URL must start with http:// or https://, got {0:?}")]
InvalidPeerUrl(String),
#[error("the token has characters that can't go in an HTTP header")]
InvalidToken,
#[error("peer: {0}")]
Peer(String),
#[error(transparent)]
Io(#[from] io::Error),
#[error(transparent)]
Json(#[from] serde_json::Error),
#[cfg(feature = "shipper")]
#[error(transparent)]
Http(#[from] reqwest::Error),
}
pub type Result<T, E = Error> = std::result::Result<T, E>;