Description
Currently if dec_hook raises an error, the error is raised as is by the corresponding decode call. This is the only place where a msgspec.ValidationError or msgspec.DecodeError isn't raised by decode. To fix this, we should:
- Update the docs to recommend raising
NotImplementedError in a dec_hook when a type isn't handled by the dec_hook
- wrap any
TypeError or ValueError raised by dec_hook in a ValidationError with additional context. Ideally we could also used chained exceptions here, although the c-api makes handling this a bit tricky.
Description
Currently if
dec_hookraises an error, the error is raised as is by the correspondingdecodecall. This is the only place where amsgspec.ValidationErrorormsgspec.DecodeErrorisn't raised bydecode. To fix this, we should:NotImplementedErrorin adec_hookwhen a type isn't handled by thedec_hookTypeErrororValueErrorraised bydec_hookin aValidationErrorwith additional context. Ideally we could also used chained exceptions here, although the c-api makes handling this a bit tricky.