mirror of
https://github.com/fluencelabs/sqlite-wasm-connector
synced 2025-04-25 00:32:14 +00:00
Implement std::error::Error for Error
This commit is contained in:
parent
fa4ceac00a
commit
626c022106
23
src/error.rs
23
src/error.rs
@ -1,6 +1,6 @@
|
|||||||
use ffi;
|
use ffi;
|
||||||
use std::convert::{From, Into};
|
use std::convert::{From, Into};
|
||||||
use std::fmt::{self, Display, Formatter};
|
use std::{error, fmt};
|
||||||
|
|
||||||
/// An error.
|
/// An error.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -77,17 +77,26 @@ impl From<ErrorKind> for Error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Display for Error {
|
impl fmt::Display for Error {
|
||||||
fn fmt(&self, formatter: &mut Formatter) -> fmt::Result {
|
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||||
match self.message {
|
match self.message {
|
||||||
Some(ref message) => Display::fmt(message, formatter),
|
Some(ref message) => message.fmt(formatter),
|
||||||
None => Display::fmt(&self.kind, formatter),
|
_ => self.kind.fmt(formatter),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Display for ErrorKind {
|
impl error::Error for Error {
|
||||||
fn fmt(&self, formatter: &mut Formatter) -> fmt::Result {
|
fn description(&self) -> &str {
|
||||||
|
match self.message {
|
||||||
|
Some(ref message) => message,
|
||||||
|
_ => "an SQLite error",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for ErrorKind {
|
||||||
|
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||||
match *self {
|
match *self {
|
||||||
ErrorKind::Unknown => write!(formatter, "an unknown SQLite result code"),
|
ErrorKind::Unknown => write!(formatter, "an unknown SQLite result code"),
|
||||||
_ => write!(formatter, "SQLite result code {}", *self as isize),
|
_ => write!(formatter, "SQLite result code {}", *self as isize),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user