Pydantic's ValidationError, for the error a validator raised, or, given None, for a field that is missing.
(raised_by_validator: Exception | None)
| 594 | |
| 595 | |
| 596 | def validation_error(raised_by_validator: Exception | None) -> Exception: |
| 597 | """Pydantic's ValidationError, for the error a validator raised, or, given |
| 598 | None, for a field that is missing.""" |
| 599 | from pydantic import BaseModel, ValidationError, field_validator |
| 600 | |
| 601 | class Agent(BaseModel): |
| 602 | llm: str |
| 603 | |
| 604 | @field_validator("llm") |
| 605 | @classmethod |
| 606 | def build(cls, value: str) -> str: |
| 607 | raise raised_by_validator |
| 608 | |
| 609 | with pytest.raises(ValidationError) as raised: |
| 610 | Agent.model_validate({"llm": SECRET} if raised_by_validator else {}) |
| 611 | return raised.value |
| 612 | |
| 613 | |
| 614 | def projects_own_error( |
nothing calls this directly
no outgoing calls
no test coverage detected