From 307431911c08d03aa07f96014280209f9bfcbfc9 Mon Sep 17 00:00:00 2001 From: gwenn Date: Sat, 4 Feb 2017 11:33:23 +0100 Subject: [PATCH] Exporting libsqlite3_sys::error::ErrorCode (#218) --- libsqlite3-sys/src/error.rs | 25 +++++++++++++++++++++++++ src/lib.rs | 3 ++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/libsqlite3-sys/src/error.rs b/libsqlite3-sys/src/error.rs index cf6f1b0..53c5ea9 100644 --- a/libsqlite3-sys/src/error.rs +++ b/libsqlite3-sys/src/error.rs @@ -2,31 +2,56 @@ use libc::c_int; use std::error; use std::fmt; +/// Error Codes #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum ErrorCode { + /// Internal logic error in SQLite InternalMalfunction, + /// Access permission denied PermissionDenied, + /// Callback routine requested an abort OperationAborted, + /// The database file is locked DatabaseBusy, + /// A table in the database is locked DatabaseLocked, + /// A malloc() failed OutOfMemory, + /// Attempt to write a readonly database ReadOnly, + /// Operation terminated by sqlite3_interrupt() OperationInterrupted, + /// Some kind of disk I/O error occurred SystemIOFailure, + /// The database disk image is malformed DatabaseCorrupt, + /// Unknown opcode in sqlite3_file_control() NotFound, + /// Insertion failed because database is full DiskFull, + /// Unable to open the database file CannotOpen, + /// Database lock protocol error FileLockingProtocolFailed, + /// The database schema changed SchemaChanged, + /// String or BLOB exceeds size limit TooBig, + /// Abort due to constraint violation ConstraintViolation, + /// Data type mismatch TypeMismatch, + /// Library used incorrectly APIMisuse, + /// Uses OS features not supported on host NoLargeFileSupport, + /// Authorization denied AuthorizationForStatementDenied, + /// 2nd parameter to sqlite3_bind out of range ParameterOutOfRange, + /// File opened that is not a database file NotADatabase, + /// SQL error or missing database Unknown, } diff --git a/src/lib.rs b/src/lib.rs index 1a10816..d4819e2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -86,6 +86,7 @@ pub use transaction::{DropBehavior, Savepoint, Transaction, TransactionBehavior} #[allow(deprecated)] pub use error::SqliteError; pub use error::Error; +pub use ffi::ErrorCode; pub use cache::CachedStatement; @@ -1506,7 +1507,7 @@ mod test { match result.unwrap_err() { Error::SqliteFailure(err, _) => { - assert_eq!(err.code, ffi::ErrorCode::ConstraintViolation); + assert_eq!(err.code, ErrorCode::ConstraintViolation); // extended error codes for constraints were added in SQLite 3.7.16; if we're // running on a version at least that new, check for the extended code