-
Notifications
You must be signed in to change notification settings - Fork 71
Description
I've recently been dealing with CBOR decoding problems after some struct types were updated in a refactor, and the error message for UnknownFieldError
has been frustrating and unhelpful when debugging. (To be clear, the decoding issues themselves were not due any problem in the cbor library.) The current error message:
cbor: found unknown field at map element index %d
I want to improve the decoding error message for unknown struct fields to include information that we already have available while decoding, namely the struct type that we are decoding into and the field name that was unexpected. One of the biggest annoyances of the existing error message is that even with the index, it gives no clue as to the level of nesting/hierarchy for the offending struct - providing the struct type in the error message mostly ameliorates that.
Proposed new error message:
cbor: found unknown field: struct '%s' has no field '%s', at map element index %d