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. diff --git a/src/lib.rs b/src/lib.rs index cb1a4f6..2efedb7 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 { + self.message.as_slice() } } @@ -311,7 +318,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<()> {