usecrate::types::FromSqlError; usecrate::types::Type; usecrate::{errmsg_to_string, ffi, Result}; use std::error; use std::fmt; use std::os::raw::c_int; use std::path::PathBuf; use std::str;
/// Enum listing possible errors from rusqlite. #[derive(Debug)] #[allow(clippy::enum_variant_names)] #[non_exhaustive] pubenum Error { /// An error from an underlying SQLite call.
SqliteFailure(ffi::Error, Option<String>),
/// Error reported when attempting to open a connection when SQLite was /// configured to allow single-threaded use only.
SqliteSingleThreadedMode,
/// Error when the value of a particular column is requested, but it cannot /// be converted to the requested Rust type.
FromSqlConversionFailure(usize, Type, Box<dyn error::Error + Send + Sync + 'static>),
/// Error when SQLite gives us an integral value outside the range of the /// requested type (e.g., trying to get the value 1000 into a `u8`). /// The associated `usize` is the column index, /// and the associated `i64` is the value returned by SQLite.
IntegralValueOutOfRange(usize, i64),
/// Error converting a string to UTF-8.
Utf8Error(str::Utf8Error),
/// Error converting a string to a C-compatible string because it contained /// an embedded nul.
NulError(std::ffi::NulError),
/// Error when using SQL named parameters and passing a parameter name not /// present in the SQL.
InvalidParameterName(String),
/// Error converting a file path to a string.
InvalidPath(PathBuf),
/// Error returned when an [`execute`](crate::Connection::execute) call /// returns rows.
ExecuteReturnedResults,
/// Error when a query that was expected to return at least one row (e.g., /// for [`query_row`](crate::Connection::query_row)) did not return any.
QueryReturnedNoRows,
/// Error when the value of a particular column is requested, but the index /// is out of range for the statement.
InvalidColumnIndex(usize),
/// Error when the value of a named column is requested, but no column /// matches the name for the statement.
InvalidColumnName(String),
/// Error when the value of a particular column is requested, but the type /// of the result in that column cannot be converted to the requested /// Rust type.
InvalidColumnType(usize, String, Type),
/// Error when a query that was expected to insert one row did not insert /// any or insert many.
StatementChangedRows(usize),
/// Error returned by /// [`functions::Context::get`](crate::functions::Context::get) when the /// function argument cannot be converted to the requested type. #[cfg(feature = "functions")] #[cfg_attr(docsrs, doc(cfg(feature = "functions")))]
InvalidFunctionParameterType(usize, Type), /// Error returned by [`vtab::Values::get`](crate::vtab::Values::get) when /// the filter argument cannot be converted to the requested type. #[cfg(feature = "vtab")] #[cfg_attr(docsrs, doc(cfg(feature = "vtab")))]
InvalidFilterParameterType(usize, Type),
/// An error case available for implementors of custom user functions (e.g., /// [`create_scalar_function`](crate::Connection::create_scalar_function)). #[cfg(feature = "functions")] #[cfg_attr(docsrs, doc(cfg(feature = "functions")))] #[allow(dead_code)]
UserFunctionError(Box<dyn error::Error + Send + Sync + 'static>),
/// Error available for the implementors of the /// [`ToSql`](crate::types::ToSql) trait.
ToSqlConversionFailure(Box<dyn error::Error + Send + Sync + 'static>),
/// Error when the SQL is not a `SELECT`, is not read-only.
InvalidQuery,
/// An error case available for implementors of custom modules (e.g., /// [`create_module`](crate::Connection::create_module)). #[cfg(feature = "vtab")] #[cfg_attr(docsrs, doc(cfg(feature = "vtab")))] #[allow(dead_code)]
ModuleError(String),
/// An unwinding panic occurs in an UDF (user-defined function). #[cfg(feature = "functions")] #[cfg_attr(docsrs, doc(cfg(feature = "functions")))]
UnwindingPanic,
/// An error returned when /// [`Context::get_aux`](crate::functions::Context::get_aux) attempts to /// retrieve data of a different type than what had been stored using /// [`Context::set_aux`](crate::functions::Context::set_aux). #[cfg(feature = "functions")] #[cfg_attr(docsrs, doc(cfg(feature = "functions")))]
GetAuxWrongType,
/// Error when the SQL contains multiple statements.
MultipleStatement, /// Error when the number of bound parameters does not match the number of /// parameters in the query. The first `usize` is how many parameters were /// given, the 2nd is how many were expected.
InvalidParameterCount(usize, usize),
/// Returned from various functions in the Blob IO positional API. For /// example, /// [`Blob::raw_read_at_exact`](crate::blob::Blob::raw_read_at_exact) will /// return it if the blob has insufficient data. #[cfg(feature = "blob")] #[cfg_attr(docsrs, doc(cfg(feature = "blob")))]
BlobSizeError, /// Error referencing a specific token in the input SQL #[cfg(feature = "modern_sqlite")] // 3.38.0 #[cfg_attr(docsrs, doc(cfg(feature = "modern_sqlite")))]
SqlInputError { /// error code
error: ffi::Error, /// error message
msg: String, /// SQL input
sql: String, /// byte offset of the start of invalid token
offset: c_int,
}, /// Loadable extension initialization error #[cfg(feature = "loadable_extension")] #[cfg_attr(docsrs, doc(cfg(feature = "loadable_extension")))]
InitError(ffi::InitError),
}
/// The conversion isn't precise, but it's convenient to have it /// to allow use of `get_raw(…).as_…()?` in callbacks that take `Error`. impl From<FromSqlError> for Error { #[cold] fn from(err: FromSqlError) -> Error { // The error type requires index and type fields, but they aren't known in this // context. match err {
FromSqlError::OutOfRange(val) => Error::IntegralValueOutOfRange(UNKNOWN_COLUMN, val),
FromSqlError::InvalidBlobSize { .. } => {
Error::FromSqlConversionFailure(UNKNOWN_COLUMN, Type::Blob, Box::new(err))
}
FromSqlError::Other(source) => {
Error::FromSqlConversionFailure(UNKNOWN_COLUMN, Type::Null, source)
}
_ => Error::FromSqlConversionFailure(UNKNOWN_COLUMN, Type::Null, Box::new(err)),
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.