diff options
Diffstat (limited to 'src/error.rs')
-rw-r--r-- | src/error.rs | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/src/error.rs b/src/error.rs index a8d3f23..129f697 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,6 +1,6 @@ use crate::types::FromSqlError; use crate::types::Type; -use crate::{errmsg_to_string, ffi}; +use crate::{errmsg_to_string, ffi, Result}; use std::error; use std::fmt; use std::os::raw::c_int; @@ -72,15 +72,18 @@ pub enum Error { /// [`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>), @@ -94,11 +97,13 @@ pub enum Error { /// 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 @@ -106,6 +111,7 @@ pub enum Error { /// 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. @@ -120,6 +126,7 @@ pub enum Error { /// [`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, } @@ -195,12 +202,7 @@ impl From<FromSqlError> for Error { // context. match err { FromSqlError::OutOfRange(val) => Error::IntegralValueOutOfRange(UNKNOWN_COLUMN, val), - #[cfg(feature = "i128_blob")] - FromSqlError::InvalidI128Size(_) => { - Error::FromSqlConversionFailure(UNKNOWN_COLUMN, Type::Blob, Box::new(err)) - } - #[cfg(feature = "uuid")] - FromSqlError::InvalidUuidSize(_) => { + FromSqlError::InvalidBlobSize { .. } => { Error::FromSqlConversionFailure(UNKNOWN_COLUMN, Type::Blob, Box::new(err)) } FromSqlError::Other(source) => { @@ -350,11 +352,10 @@ pub unsafe fn error_from_handle(db: *mut ffi::sqlite3, code: c_int) -> Error { error_from_sqlite_code(code, message) } -macro_rules! check { - ($funcall:expr) => {{ - let rc = $funcall; - if rc != crate::ffi::SQLITE_OK { - return Err(crate::error::error_from_sqlite_code(rc, None).into()); - } - }}; +pub fn check(code: c_int) -> Result<()> { + if code != crate::ffi::SQLITE_OK { + Err(crate::error::error_from_sqlite_code(code, None)) + } else { + Ok(()) + } } |