Trying to get a better error message out of Lemmy 0.18.1 unmatched enum
Trying to get a better error message out of Lemmy 0.18.1 unmatched enum
I don't know Rust, but trying to hack on Lemmy 0.18.1 enough to get a better error message out.
error: data did not match any variant of untagged enum AnnouncableActivities
where: crates/apub/src/activities/community/announce.rs, line: 46
That seems to be the function parameters themselves?
Is the error caused by RawAnnouncableActivities not matching the enum AnnouncableActivities and the try_into?
warn!("zebratrace receive {:?}", self);
Works for adding logging, but I'd like the code to log self only when the enum does not match (errors). Thank you.
Your analysis sounds correct -
data did not match any variant of untagged enum
is definitely fromserde
IIRC - but I can't say for certain just by looking at the code.Try changing line 48 to this:
(This probably isn't the best way to do this, but it's what I came up with off the top of my head :P)
Serde handles untagged enums in the way that it tries to deserialize every variant of that enum from top to bottom with the given data, and returns the first one that doesn’t throw an error. The error indicates that all of them threw an error when trying to deserialize the data.
Compiler didn't like your code:
Yeah, I thought I was botching something important.
This should work: