Skip to content

Commit 0215141

Browse files
committed
restore custom formatter errors
`InvalidCustomFormatterValue` grows in scope of responsibility, as `FormatUnmarshalError` is no longer available. Refs: python-openapi/openapi-core#562 Signed-off-by: Mike Fiedler <[email protected]>
1 parent 100940c commit 0215141

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

Diff for: pyramid_openapi3/exceptions.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from dataclasses import dataclass
44
from openapi_core.exceptions import OpenAPIError
5-
from openapi_core.unmarshalling.schemas.exceptions import FormatUnmarshalError
5+
from openapi_core.unmarshalling.schemas.exceptions import UnmarshallerError
66
from pyramid.httpexceptions import HTTPBadRequest
77
from pyramid.httpexceptions import HTTPInternalServerError
88
from pyramid.request import Request
@@ -49,10 +49,13 @@ def __str__(self) -> str:
4949

5050

5151
@dataclass
52-
class InvalidCustomFormatterValue(FormatUnmarshalError):
52+
class InvalidCustomFormatterValue(UnmarshallerError):
5353
"""Value failed to format with a custom formatter."""
5454

5555
field: str
56+
value: str
57+
type: str # noqa: A003 # we use `type` as a dataclass field name
58+
original_exception: Exception
5659

5760
def __str__(self) -> str:
5861
"""Provide more control over error message."""

Diff for: pyramid_openapi3/tests/test_extract_errors.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ def unique_name(self, name: str) -> bool:
572572
if name in ["alice", "bob"]:
573573
raise RequestValidationError(
574574
errors=[
575-
InvalidCustomFormatterValue( # type: ignore
575+
InvalidCustomFormatterValue(
576576
value=name,
577577
type="unique-name",
578578
original_exception=Exception(

0 commit comments

Comments
 (0)