woile commented on code in PR #2587:
URL: https://github.com/apache/avro/pull/2587#discussion_r1395510053
##########
lang/rust/avro/src/error.rs:
##########
@@ -478,6 +478,9 @@ pub enum Error {
#[error("Invalid Avro data! Cannot read codec type from value that is not
Value::Bytes.")]
BadCodecMetadata,
+
+ #[error("Schemas are not compatible. '{0}'")]
+ CompatibilityError(String),
Review Comment:
Should this be a separate error? I don't think it's wise to keep adding
errors to this `Error`.
As a user, if you try to deserialize and fails, you shouldn't have to handle
this error.
```rs
match Schema::parse_str(reader_raw_schema) {
CompatibilityError => unreachable!()
}
```
I think compatibility should have its own enum with a set of errors so the
user can react to them properly.
```rs
#[derive(Error, Debug)]
pub enum CompatibilityError {
#[error("We got {input}, but {output} was expected")]
WrongKind { input: SchemaKind, output: SchemaKind},
#[error("Reader's symbols must contain all writer's symbols")]
MissingSymbols,
#[error("Could not calculate compatibility")]
Inconclusive
}
```
And more...
Thoughts @martin-g @marcosschroh ?
--
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]