jcrist · GitHub

@jcrist

This modifies decoding of custom types to wrap errors raised by a
`dec_hook` with `ValidationError`. Only `TypeError` or `ValueError` (and
subclasses) exceptions are wrapped, all other exceptions are raised
directly.
If an exception is wrapped with a `ValidationError`, the original
exception is set as the `__cause__` (and `__context__`). This means the
original exception will still show up in tracebacks, and is available
for introspection if needed.
This also changes the recommendation for raising `TypeError` on
unsupported types in `dec_hook`/`enc_hook` to raising a
`NotImplementedError`. No previous functionality was based on this
recommendation, so this isn't a breaking change in anyway, just a change
in recommendation of how best to use `msgspec`.

Read the original on github.com ↗