Shouldn't panic on missing event fields
ara4n opened this issue · 1 comments
In accordance with Postel's law, it'd be good to be more forgiving of missing event fields (related to #48). Currently any mjson::path()
that fails to find a path panics entirely with panic!("Could not find {} in {} (lost at {})", path, json.pretty(), p)
. I obviously don't know any rust, but I'm assuming this would better be a Result rather than a panic so it can be trapped nicely in from_room_json
and similar, rather than having to do the partial solution I've done in #49 for the specific case of redactions.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
Yeah, using the builtin json path functions would be a much loved improvement. The mjson functions prevent the need for a billion unwrap().unwrap().unwrap() when the majority of event packets seem to work out fine.
Redoing it with more thorough error checking would make the code here explode in complexity, a problem I've wrestled with cleanly solving for some time. Probably about time for a macro.