mirror of
https://github.com/isar/rusqlite.git
synced 2025-10-25 18:38:54 +08:00
Merge remote-tracking branch 'jgallagher/master' into vtab
This commit is contained in:
14
src/error.rs
14
src/error.rs
@@ -2,7 +2,7 @@ use std::error;
|
||||
use std::fmt;
|
||||
use std::path::PathBuf;
|
||||
use std::str;
|
||||
use libc::c_int;
|
||||
use std::os::raw::c_int;
|
||||
use {ffi, errmsg_to_string};
|
||||
use types::Type;
|
||||
|
||||
@@ -25,6 +25,11 @@ pub enum Error {
|
||||
/// the requested Rust type.
|
||||
FromSqlConversionFailure(usize, Type, Box<error::Error + Send + Sync>),
|
||||
|
||||
/// 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 `c_int` is the column index, and
|
||||
/// the associated `i64` is the value returned by SQLite.
|
||||
IntegralValueOutOfRange(c_int, i64),
|
||||
|
||||
/// Error converting a string to UTF-8.
|
||||
Utf8Error(str::Utf8Error),
|
||||
|
||||
@@ -105,6 +110,9 @@ impl fmt::Display for Error {
|
||||
i,
|
||||
err)
|
||||
}
|
||||
Error::IntegralValueOutOfRange(col, val) => {
|
||||
write!(f, "Integer {} out of range at index {}", val, col)
|
||||
}
|
||||
Error::Utf8Error(ref err) => err.fmt(f),
|
||||
Error::NulError(ref err) => err.fmt(f),
|
||||
Error::InvalidParameterName(ref name) => write!(f, "Invalid parameter name: {}", name),
|
||||
@@ -141,6 +149,7 @@ impl error::Error for Error {
|
||||
"SQLite was compiled or configured for single-threaded use only"
|
||||
}
|
||||
Error::FromSqlConversionFailure(_, _, ref err) => err.description(),
|
||||
Error::IntegralValueOutOfRange(_, _) => "integral value out of range of requested type",
|
||||
Error::Utf8Error(ref err) => err.description(),
|
||||
Error::InvalidParameterName(_) => "invalid parameter name",
|
||||
Error::NulError(ref err) => err.description(),
|
||||
@@ -170,6 +179,7 @@ impl error::Error for Error {
|
||||
Error::Utf8Error(ref err) => Some(err),
|
||||
Error::NulError(ref err) => Some(err),
|
||||
|
||||
Error::IntegralValueOutOfRange(_, _) |
|
||||
Error::SqliteSingleThreadedMode |
|
||||
Error::InvalidParameterName(_) |
|
||||
Error::ExecuteReturnedResults |
|
||||
@@ -197,7 +207,7 @@ pub fn error_from_sqlite_code(code: c_int, message: Option<String>) -> Error {
|
||||
Error::SqliteFailure(ffi::Error::new(code), message)
|
||||
}
|
||||
|
||||
pub fn error_from_handle(db: *mut ffi::Struct_sqlite3, code: c_int) -> Error {
|
||||
pub fn error_from_handle(db: *mut ffi::sqlite3, code: c_int) -> Error {
|
||||
let message = if db.is_null() {
|
||||
None
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user