jcrist / msgspec

A fast serialization and validation library, with builtin support for JSON, MessagePack, YAML, and TOML
https://jcristharif.com/msgspec/
BSD 3-Clause "New" or "Revised" License
2.01k stars 59 forks source link

Consider making `DecodeError` and `ValidationError` inherit from `ValueError` #634

Open vytas7 opened 5 months ago

vytas7 commented 5 months ago

Description

In many scenarios and libraries one assumes that validation errors inherit from ValueError, however, msgspec's exception classes do not. Would it be possible to make DecodeError and ValidationError subclasses of ValueError somewhere in the hierarchy?

jcrist commented 5 months ago

Makes sense to me, happy to make this change. This would be a breaking change of course, but since we're still in 0.* that shouldn't be unexpected.