From 25b32e0ede8e8971937456304f7c553787e55326 Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Mon, 14 Dec 2015 20:36:18 -0800 Subject: [PATCH] Manually implement Debug for DbError --- src/error.rs | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/error.rs b/src/error.rs index d627943b..b19bdd2c 100644 --- a/src/error.rs +++ b/src/error.rs @@ -15,7 +15,7 @@ use types::Type; include!(concat!(env!("OUT_DIR"), "/sqlstate.rs")); /// A Postgres error or notice. -#[derive(Clone, PartialEq, Eq, Debug)] +#[derive(Clone, PartialEq, Eq)] pub struct DbError { /// The field contents are ERROR, FATAL, or PANIC (in an error message), /// or WARNING, NOTICE, DEBUG, INFO, or LOG (in a notice message), or a @@ -137,6 +137,29 @@ impl DbErrorNew for DbError { } } +// manual impl to leave out _p +impl fmt::Debug for DbError { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("DbError") + .field("severity", &self.severity) + .field("code", &self.code) + .field("message", &self.message) + .field("detail", &self.detail) + .field("hint", &self.hint) + .field("position", &self.position) + .field("where_", &self.where_) + .field("schema", &self.schema) + .field("table", &self.table) + .field("column", &self.column) + .field("datatype", &self.datatype) + .field("constraint", &self.constraint) + .field("file", &self.file) + .field("line", &self.line) + .field("routine", &self.routine) + .finish() + } +} + impl fmt::Display for DbError { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { write!(fmt, "{}: {}", self.severity, self.message)