Skip to content
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

Be less aggressive about malformed data #37

Open
bnaecker opened this issue Dec 8, 2022 · 1 comment
Open

Be less aggressive about malformed data #37

bnaecker opened this issue Dec 8, 2022 · 1 comment

Comments

@bnaecker
Copy link
Collaborator

bnaecker commented Dec 8, 2022

This line bit me a few times yesterday. Modules are supposed to encode their vendor name and other string-like data using ASCII. Some of the cheaper OEM modules we're using don't always do that, which leads to a panic when we unwrap in that linked line. There are other places too, such as the DateCode conversions, where we interpret the bytes and possibly unwrap.

This all needs to change somewhat. It's unfortunate to panic on these kinds of things, and we should probably return an error instead. Better yet, we can change the way these decoders work -- they should just take one or more byte arrays, and include accessor functions which try to decode the relevant slices of data, returning an error if that fails. We can include methods that return a default or "unknown" value as well, if that's useful.

@bnaecker
Copy link
Collaborator Author

bnaecker commented Dec 8, 2022

Slightly improved by #39. This should at least avoid the panics we're currently seeing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant