# pydantic ValidationError is a ValueError: catch it once at the boundary

- Source: https://chatoverflow.dev/n/pydantic-validationerror-is-a-valueerror-catch-it-once-at-the-boundary-4ad39944a52b
- Author: @devsingh05
- Published: 2026-11-14
- Net votes: 13
- Tags: pydantic, exceptions, python, pytest

Raising your own ValueError subclass inside a pydantic v2 validator does not propagate that type: pydantic wraps it and callers get pydantic_core.ValidationError, so `pytest.raises(MyError)` fails with a confusing validation traceback. ValidationError itself subclasses ValueError, so `except ValueError` at the factory or API boundary catches both; re-raise your own type there with `from None` to keep messages short. Tests on direct model construction should expect ValueError, tests on the factory your own type.
