martin-g commented on code in PR #230:
URL: https://github.com/apache/avro-rs/pull/230#discussion_r2218818490


##########
avro/src/error.rs:
##########
@@ -21,8 +21,1154 @@ use crate::{
 };
 use std::{error::Error as _, fmt};
 
+/// Errors encounterd by Avro.
+///
+/// To inspect the details of the error use [`details`](Self::details) or 
[`into_details`](Self::into_details)
+/// to get a [`Details`] which contains more precise error information.
+///
+/// See [`Details`] for all possible errors.
+#[derive(thiserror::Error, Debug)]
+#[repr(transparent)]
+#[error(transparent)]
+pub struct Error {
+    details: Box<Details>,
+}
+
+impl Error {
+    pub fn new(details: Details) -> Self {
+        Self {
+            details: Box::new(details),
+        }
+    }
+
+    pub fn details(&self) -> &Details {
+        &self.details
+    }
+
+    pub fn into_details(self) -> Details {
+        *self.details
+    }
+}
+
+/// Functions for constructing a specific error type.
+#[allow(non_snake_case, reason = "Want to mimic the `Details` variants")]
+impl Error {
+    /// Construct a new [`Error`] with a [`Details::SnappyCrc32`].
+    pub fn SnappyCrc32(expected: u32, actual: u32) -> Self {

Review Comment:
   > We could remove them completely but then a lot more lines will have to be 
changed, if you want that let me know and I'll do it.
   
   We change those lines anyway in this PR.
   Please make the change for just a few of the variants to see how it looks 
like and then we can decide!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to