mirror of
https://github.com/launchbadge/sqlx.git
synced 2026-01-19 23:26:32 +00:00
* WAL * sync = NORMAL, thought on this for awhile, all signs point to this being a very good default for WAL usage * separate worker thread per SQLite connection
36 lines
705 B
Rust
36 lines
705 B
Rust
use crate::error::DatabaseError;
|
|
use libsqlite3_sys::sqlite3_errstr;
|
|
use std::ffi::CStr;
|
|
use std::os::raw::c_int;
|
|
|
|
pub struct SqliteError {
|
|
#[allow(dead_code)]
|
|
code: c_int,
|
|
message: String,
|
|
}
|
|
|
|
impl SqliteError {
|
|
pub(crate) fn new(code: c_int) -> Self {
|
|
#[allow(unsafe_code)]
|
|
let message = unsafe {
|
|
let err = sqlite3_errstr(code);
|
|
debug_assert!(!err.is_null());
|
|
|
|
CStr::from_ptr(err)
|
|
};
|
|
|
|
Self {
|
|
code,
|
|
message: message.to_string_lossy().into_owned(),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl DatabaseError for SqliteError {
|
|
fn message(&self) -> &str {
|
|
&self.message
|
|
}
|
|
}
|
|
|
|
impl_fmt_error!(SqliteError);
|