From 6d795caaedc233266a62966ef045ed7981248e21 Mon Sep 17 00:00:00 2001 From: Joshua Schneider Date: Wed, 4 Feb 2015 21:08:44 +0100 Subject: [PATCH 1/4] Implement standard Error trait for SqliteError --- src/lib.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index cb1a4f6..903793c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -57,6 +57,7 @@ extern crate libc; use std::mem; use std::ptr; use std::fmt; +use std::error; use std::rc::{Rc}; use std::cell::{RefCell, Cell}; use std::ffi::{CString}; @@ -100,8 +101,14 @@ pub struct SqliteError { } impl fmt::Display for SqliteError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - write!(f, "SqliteError( code: {}, message: {} )", self.code, self.message) + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{} (SQLite error {})", self.message, self.code) + } +} + +impl error::Error for SqliteError { + fn description(&self) -> &str { + ffi::code_to_str(self.code) } } From 937eedbe6179bea851db0b6243334a059f615666 Mon Sep 17 00:00:00 2001 From: John Gallagher Date: Fri, 13 Feb 2015 15:44:24 -0500 Subject: [PATCH 2/4] Fix for latest rustc changes --- src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index cb1a4f6..ecfd540 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -311,7 +311,8 @@ impl SqliteConnection { /// This is functionally equivalent to the `Drop` implementation for `SqliteConnection` except /// that it returns any error encountered to the caller. pub fn close(self) -> SqliteResult<()> { - self.db.borrow_mut().close() + let mut db = self.db.borrow_mut(); + db.close() } fn decode_result(&self, code: c_int) -> SqliteResult<()> { From 7a430c0fde58be3598f4118f82325be491362750 Mon Sep 17 00:00:00 2001 From: John Gallagher Date: Fri, 13 Feb 2015 15:48:11 -0500 Subject: [PATCH 3/4] Use existing message instead of `ffi::code_to_str` in Error trait --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 24ad3cf..2efedb7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -108,7 +108,7 @@ impl fmt::Display for SqliteError { impl error::Error for SqliteError { fn description(&self) -> &str { - ffi::code_to_str(self.code) + self.message.as_slice() } } From 31ea62a176dbf2b796de378c30c676dcaf66a80a Mon Sep 17 00:00:00 2001 From: John Gallagher Date: Fri, 13 Feb 2015 15:49:16 -0500 Subject: [PATCH 4/4] Bump version to 0.0.9 --- Cargo.toml | 2 +- Changelog.md | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index d62c270..0d322ba 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rusqlite" -version = "0.0.8" +version = "0.0.9" authors = ["John Gallagher "] description = "Ergonomic wrapper for SQLite" homepage = "https://github.com/jgallagher/rusqlite" diff --git a/Changelog.md b/Changelog.md index 395d447..3ee1ed3 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,8 @@ +# Version 0.0.9 (2015-02-13) + +* Updates to track latest rustc changes. +* Implement standard `Error` trait for `SqliteError`. + # Version 0.0.8 (2015-02-04) * Updates to track latest rustc changes.