use thiserror::Error;
use crate::reader::ColumnFailure;
#[derive(Error, Debug)]
pub enum Error {
#[error("Unable to retrieve number of columns in result set.\n{0}")]
UnableToRetrieveNumCols(odbc_api::Error),
#[error(
"There is a problem with the SQL type of the column with name: {} and index {}:\n{source}",
name,
index
)]
ColumnFailure {
name: String,
index: usize,
source: ColumnFailure,
},
#[error(
"The Odbc buffer is limited to a size of {max_bytes_per_batch} bytes. Yet a single row \
does require up to {bytes_per_row}. This means the buffer is not large enough to hold a \
single row of data. Please note that the buffers in ODBC must always be able to hold the \
largest possible value of variadic types. You should either set a higher upper bound for \
the buffer size, or limit the length of the variadic columns."
)]
OdbcBufferTooSmall {
max_bytes_per_batch: usize,
bytes_per_row: usize,
},
#[cfg(target_os = "windows")]
#[error(
"Expected the database to return UTF-16, yet what came back was not valid UTF-16. Precise \
encoding error: {source}. This is likely a bug in your ODBC driver not supporting wide \
method calls correctly."
)]
EncodingInvalid { source: std::char::DecodeUtf16Error },
#[cfg(not(target_os = "windows"))]
#[error(
"Expected the database to return UTF-8, yet what came back was not valid UTF-8. According \
to the ODBC standard the encoding is specified by your system locale. So you may want to \
check your environment and whether it specifies to use an UTF-8 charset. However it is \
worth noting that drivers take some liberty with the interpretation. Your connection \
string and other configurations specific to your database may also influence client side \
encoding. Precise encoding error: {source}"
)]
EncodingInvalid { source: std::string::FromUtf8Error },
}