Skip to content

Wrap errors raised by dec_hook in ValidationError #456

Description

@jcrist

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions