Kriskras99 commented on code in PR #230:
URL: https://github.com/apache/avro-rs/pull/230#discussion_r2218800818
##########
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:
I've marked the construction functions as `pub(crate)` for now, let me know
if you want to completely remove them.
--
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]