Add error flags #3
Open
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.
Improve Error Handling
This pull request adds error wrapping at each level along with appropriate state dumps for better error tracking on parsing failures. Crucially, adding state dumps for specific debugging issues becomes easier, since all we need to do is modify the error string.
Examples
Current: When receiving an IAm message with a VendorID below 256, the
whois-clientscript ends with anErrTooShortToMarshalBinary.Updated:
The script adds an error trace at each layer. The unmarshal function declares that it is an UnconfirmedIAm, and that the binary length doesn't match the marshal length (since all VendorID's are currently encoded as 16bit).
Current: When receiving a CACK with a string data object, the
rp-clientends with anErrWongObjectCountUpdated:
The script adds an error trace at each layer. The decode function outputs the number of objects detected as context, so we cna see that the parser is detecting too many objects.
References
Uses the
github.com/pkg/errorslibrary to wrap errors with new context at each layer.Resolves #2