mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-26 19:41:37 +08:00
Implement standard Error trait for SqliteError
This commit is contained in:
parent
4ca7b4964f
commit
6d795caaed
11
src/lib.rs
11
src/lib.rs
@ -57,6 +57,7 @@ extern crate libc;
|
|||||||
use std::mem;
|
use std::mem;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
use std::error;
|
||||||
use std::rc::{Rc};
|
use std::rc::{Rc};
|
||||||
use std::cell::{RefCell, Cell};
|
use std::cell::{RefCell, Cell};
|
||||||
use std::ffi::{CString};
|
use std::ffi::{CString};
|
||||||
@ -100,8 +101,14 @@ pub struct SqliteError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for SqliteError {
|
impl fmt::Display for SqliteError {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
write!(f, "SqliteError( code: {}, message: {} )", self.code, self.message)
|
write!(f, "{} (SQLite error {})", self.message, self.code)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl error::Error for SqliteError {
|
||||||
|
fn description(&self) -> &str {
|
||||||
|
ffi::code_to_str(self.code)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user