Reveal SQLite's extended error code

This commit is contained in:
Julius de Bruijn 2020-07-01 18:30:28 +02:00 committed by Ryan Leckey
parent eda0b7dea4
commit 24d626b883

View File

@ -2,7 +2,7 @@ use std::error::Error as StdError;
use std::ffi::CStr;
use std::fmt::{self, Display, Formatter};
use std::os::raw::c_int;
use std::str::from_utf8_unchecked;
use std::{borrow::Cow, str::from_utf8_unchecked};
use libsqlite3_sys::{sqlite3, sqlite3_errmsg, sqlite3_extended_errcode};
@ -46,6 +46,12 @@ impl Display for SqliteError {
impl StdError for SqliteError {}
impl DatabaseError for SqliteError {
/// The extended result code.
#[inline]
fn code(&self) -> Option<Cow<'_, str>> {
Some(format!("{}", self.code).into())
}
#[inline]
fn message(&self) -> &str {
&self.message