-
Notifications
You must be signed in to change notification settings - Fork 97
Error logging in converters [DEVINFRA-1018] #1244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
a424857
added error logs
adrian-kong 3757022
remove take until for inclusiveness
adrian-kong 593f15d
if else
adrian-kong 8c63cb1
eprintln error
adrian-kong e5a83a5
terminate on error
adrian-kong 728671c
lint
adrian-kong 70907a4
remove msglog
adrian-kong 15ee54e
print err
adrian-kong 0ab626c
Merge remote-tracking branch 'origin/adrian/sbp_converters_logging' i…
adrian-kong 4f2df9e
advance buffer so stream will terminate, log fatal errors too
efd5795
more fluent style
adrian-kong 31387c2
terminate on eof fix test
adrian-kong bd80a20
Merge branch 'master' into adrian/sbp_converters_logging
adrian-kong 3628d09
Error out if two consecutive EOF errors occur
d17370c
Adds some testing for json converters
adrian-kong ede8abc
Merge branch 'master' into adrian/sbp_converters_logging
adrian-kong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| mod common; | ||
|
|
||
| use crate::common::{data_path, find_project_root}; | ||
| use assert_cmd::cargo::CommandCargoExt; | ||
| use assert_cmd::Command; | ||
|
|
||
| /// Asserts termination of json decoder on broken inputs | ||
| #[test] | ||
| fn test_json_converters_termination() { | ||
adrian-kong marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| let input_path = data_path("test_data/errors/error_eof.json"); | ||
| let mut cmd = Command::cargo_bin("json2sbp").unwrap(); | ||
| cmd.arg(input_path) | ||
| .assert() | ||
| .success() | ||
| .stderr("expected `,` or `}` at line 1 column 185\n"); | ||
| } | ||
|
|
||
| /// Asserts error for invalid msg_type | ||
| #[test] | ||
| fn test_json_untagged() { | ||
| let input_path = data_path("test_data/errors/error_untagged.json"); | ||
| let mut cmd = Command::cargo_bin("json2sbp").unwrap(); | ||
| cmd.arg(input_path) | ||
| .assert() | ||
| .success() | ||
| .stderr("data did not match any variant of untagged enum JsonInput\n"); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| {"crc":10555,"length":17,"msg_type":2304,"payload":"xYZjQJhhAWwAYhDy/3v+DgA=","preamble":85,"sender":51228,"tow":1080264389,"tow_f":152,"acc_x":353,"acc_y":108,"acc_z":4194,"gyr_x":114{ | ||
| {"crc":10555,"length":17,"msg_type":2304,"payload":"xYZjQJhhAWwAYhDy/3v+DgA=","preamble":85,"sender":51228,"tow":1080264389,"tow_f":152,"acc_x":353,"acc_y":108,"acc_z":4194,"gyr_x":114,"gyr_y":-389,"gyr_z":14} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {"crc":10555,"length":17,"msg_type":"2304","payload":"xYZjQJhhAWwAYhDy/3v+DgA=","preamble":85,"sender":51228,"tow":1080264389,"tow_f":152,"acc_x":353,"acc_y":108,"acc_z":4194,"gyr_x":114,"gyr_y":-389,"gyr_z":14} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was trying to figure out a better way instead of holding this - felt hacky but i guess it works 👍 - or maybe just
eprintlninside decode, thought the dencode errors meant retry decoding so we needed two error typesThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree that the solution is a bit hacky. However, since these are library functions, it didn't feel right to add
eprintlnthere (printing errors should be an application layer behavior).