You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Description
This PR makes it so that if at any point in the parsing of sbp messages
the parsing fails, it has the option of falling back to an
InvalidMessage which can then be written to the output. The way this PR
acheives this goal is through some major breaking changes. The idea is
that when errors are thrown throughout the process, we store all that
local information in the constructed error. That way, choosing how to
write the output can become as simple as matching on the thrown error
and then basically writing `SbpMessage::from(error)`. This enables us to
keep the previous behavior of skipping errors or returning on errors
simply by refusing to handle the errors.
`sbp2json`, `json2sbp` & `json2json` now have a new optional arg
`--error_handler` which allows the following options `skip`, `return` or
`ToInvalid`. that skip and return are the equivalent of the false and
true passed to fatal-errors arg which as been removed.
Care was taken to remove some panics in the parsing of SBP which could
cause some types of invalid messages to be lost.
Finally this PR does not do things like try to recover from being passed
in malformed json or given an I/O error. In case of those error, if the
`ToInvalid` option is passed, the code will panic.
Some issues with this PR --
1) it has a lot of breaking changes, and it kind of does a lot. Just
want to make sure people like the direction i went in.
2) the lack of recovering from malformed json means I left json2json to
panic if given ToInvalid as an option.
3) It has no unit tests. I wanted some eyes on this code and proposed
solution before totally getting it over the finish line.
# JIRA Reference
https://swift-nav.atlassian.net/browse/DEVINFRA-1220
---------
Co-authored-by: Jason Mobarak <[email protected]>
Co-authored-by: Patrick Crumley <[email protected]>
Co-authored-by: Patrick Crumley <[email protected]>
Co-authored-by: Jason Mobarak <[email protected]>
let sbp_msg = sbp::messages::Sbp::(((t.msg.name|lower_acronyms)))(serde_json::from_str(std::str::from_utf8(json_buffer.as_slice()).unwrap().to_string().as_str()).unwrap());
0 commit comments