This is an automated email from the ASF dual-hosted git repository.
mgrigorov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/avro.git
The following commit(s) were added to refs/heads/master by this push:
new 16ae8952b Implement Debug for Error. (#2416)
16ae8952b is described below
commit 16ae8952b00d1a14a7d31a14587cd408de041b31
Author: Kousuke Saruta <[email protected]>
AuthorDate: Fri Aug 4 16:43:20 2023 +0900
Implement Debug for Error. (#2416)
---
lang/rust/avro/src/error.rs | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/lang/rust/avro/src/error.rs b/lang/rust/avro/src/error.rs
index 97c929ad7..5b8b39ce3 100644
--- a/lang/rust/avro/src/error.rs
+++ b/lang/rust/avro/src/error.rs
@@ -19,9 +19,9 @@ use crate::{
schema::{Name, SchemaKind},
types::ValueKind,
};
-use std::fmt;
+use std::{error::Error as _, fmt};
-#[derive(thiserror::Error, Debug)]
+#[derive(thiserror::Error)]
pub enum Error {
#[error("Bad Snappy CRC32; expected {expected:x} but got {actual:x}")]
SnappyCrc32 { expected: u32, actual: u32 },
@@ -464,3 +464,13 @@ impl serde::de::Error for Error {
Error::DeserializeValue(msg.to_string())
}
}
+
+impl fmt::Debug for Error {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ let mut msg = self.to_string();
+ if let Some(e) = self.source() {
+ msg.extend([": ", &e.to_string()]);
+ }
+ write!(f, "{}", msg)
+ }
+}