use thiserror::Error;
#[derive(Error, Debug)]
pub enum SqlError {
#[error("unsupported URL scheme: {0}")]
UnsupportedScheme(String),
#[error("invalid connection URL: {0}")]
InvalidUrl(String),
#[error("backend '{0}' is not enabled — recompile with the appropriate feature")]
BackendDisabled(String),
#[error("connection failed: {0}")]
ConnectionFailed(String),
#[error("query failed: {0}")]
QueryFailed(String),
#[error("bulk path unavailable: {0}")]
BulkUnavailable(String),
#[error("TLS error: {0}")]
TlsError(String),
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
#[cfg(feature = "ssh")]
#[error("SSH host key mismatch for {host}:{port}")]
SshHostKeyMismatch { host: String, port: u16 },
#[cfg(feature = "ssh")]
#[error("SSH unknown host {host}:{port}")]
SshUnknownHost {
host: String,
port: u16,
algorithm: String,
fingerprint: String,
key: Box<russh::keys::ssh_key::PublicKey>,
},
#[error("timeout")]
Timeout,
#[error(
"cell too large: row {row}, column {column:?} is {size} bytes, \
exceeds the {cap}-byte cap (raise SizeGuards::max_cell_bytes, or \
stream the column out via --format csv/jsonl)"
)]
CellTooLarge {
row: u64,
column: String,
size: usize,
cap: usize,
},
#[error(
"row too large: row {row} is {size} bytes, exceeds the \
{cap}-byte cap (raise SizeGuards::max_row_bytes, or stream via \
--format csv/jsonl)"
)]
RowTooLarge { row: u64, size: usize, cap: usize },
#[error(
"result too large: buffered {rows_buffered} rows exceeding the \
{cap}-byte total cap (raise SizeGuards::max_total_buffered_bytes, \
or stream the result via the cursor API / --format csv/jsonl)"
)]
BufferTooLarge { rows_buffered: u64, cap: usize },
#[error("registry error: {0}")]
RegistryError(String),
}