mirror of
https://github.com/launchbadge/sqlx.git
synced 2026-04-08 11:17:12 +00:00
De-duplicate error impls and forward MySqlConnection/PgConnection to crate root
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
use crate::error::DatabaseError;
|
||||
use crate::postgres::protocol::Response;
|
||||
use std::fmt::{self, Debug, Display};
|
||||
|
||||
pub struct PgError(pub(super) Box<Response>);
|
||||
|
||||
impl crate::error::DatabaseError for PgError {
|
||||
impl DatabaseError for PgError {
|
||||
fn message(&self) -> &str {
|
||||
&self.0.message
|
||||
}
|
||||
@@ -29,25 +29,4 @@ impl crate::error::DatabaseError for PgError {
|
||||
}
|
||||
}
|
||||
|
||||
impl Debug for PgError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
use crate::error::DatabaseError;
|
||||
|
||||
f.debug_struct("DatabaseError")
|
||||
.field("message", &self.message())
|
||||
.field("details", &self.details())
|
||||
.field("hint", &self.hint())
|
||||
.field("table_name", &self.table_name())
|
||||
.field("column_name", &self.column_name())
|
||||
.field("constraint_name", &self.constraint_name())
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for PgError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
use crate::error::DatabaseError;
|
||||
|
||||
f.pad(self.message())
|
||||
}
|
||||
}
|
||||
impl_fmt_error!(PgError);
|
||||
|
||||
Reference in New Issue
Block a user