Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(field-exception): pydantic error message template #282

Merged
merged 1 commit into from
Aug 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions projects/fal/src/fal/exceptions/_base.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

from dataclasses import dataclass
from typing import Sequence


class FalServerlessException(Exception):
Expand Down Expand Up @@ -40,11 +39,13 @@ class FieldException(FalServerlessException):
status_code: int = 422
type: str = "value_error"

def to_pydantic_format(self) -> Sequence[dict]:
return [
{
"loc": ["body", self.field],
"msg": self.message,
"type": self.type,
}
]
def to_pydantic_format(self) -> dict[str, list[dict]]:
return dict(
detail=[
{
"loc": ["body", self.field],
"msg": self.message,
"type": self.type,
}
]
)
Loading