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

Gracefully handle errors when decoding encapsulated commands #769

Open
bjyoungblood opened this issue May 15, 2023 · 0 comments
Open

Gracefully handle errors when decoding encapsulated commands #769

bjyoungblood opened this issue May 15, 2023 · 0 comments

Comments

@bjyoungblood
Copy link
Member

Summary

Currently, an error encountered while decoding a Z/IP Packet's encapsulated command results in a raising a MatchError here: https://github.com/smartrent/grizzly/blob/main/lib/grizzly/zwave/commands/zip_packet.ex#L83. The resulting exception should (hopefully) include the parameter and value that failed to be decoded, but the rest of the message binary is important context we don't want to lose.


To address the immediate issue, let's add a cause field to Grizzly.ZWave.DecodeError. When decoding something that can itself return a DecodeError, the original DecodeError should become the cause of the new one to maintain context.

For decoding errors that occur via a call to Grizzly.send_command/4, we should continue to raise in order to preserve the current behavior.

For the decoding errors encountered in the unsolicited server, we should add a new Grizzly option that allows consumers to pass in an error handler function. If provided, the unsolicited server will report decoding errors to that function. If no function is provided, the unsolicited server should instead log an error with as much detail as possible.

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