Skip to content

Commit e30a778

Browse files
authored
Clarify error message
1 parent a791a29 commit e30a778

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

exca/helpers.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,9 +367,10 @@ def _inject_type_on_serialization(
367367
) -> dict[str, tp.Any]:
368368
result: dict[str, tp.Any] = handler(self)
369369
key = self._exca_discriminator_key
370+
name = self.__class__.__name__
370371
if key in result:
371-
raise ValueError("Cannot use field {key!r}. It is reserved.")
372-
result[key] = f"{self.__class__.__name__}"
372+
raise ValueError(f"Cannot use field {key!r} in {self.__class__}, it is reserved.")
373+
result[key] = name
373374
return result
374375

375376
@pydantic.model_validator(mode="wrap") # noqa # the decorator position is correct

0 commit comments

Comments
 (0)