Skip to content

Commit

Permalink
0.1.3: improved TOMLBaseSingleError docstring and add .msg attribute
Browse files Browse the repository at this point in the history
maps closer to pydantic errors; should make more sense for devs coming from pydantic
  • Loading branch information
markjoshwel committed Mar 4, 2024
1 parent 29f7cf5 commit 3f609b2
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tomlantic/tomlantic.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,17 @@ class TomlanticException(Exception):


class TOMLBaseSingleError(TomlanticException):
"""base exception class for single errors, e.g. TOMLMissingError, TOMLValueError"""
"""
base exception class for single errors, e.g. TOMLMissingError, TOMLValueError
attributes:
- loc: `tuple[str]`
- msg: `str`
- pydantic_error: `pydantic_core.ErrorDetails`
"""

loc: Tuple[str, ...]
msg: str = ""
pydantic_error: ErrorDetails

def __init__(
Expand All @@ -158,6 +166,7 @@ def __init__(
self.loc = loc
self.pydantic_error = pydantic_error
super().__init__(*args)
self.msg = str(self)


class TOMLMissingError(TOMLBaseSingleError):
Expand Down

0 comments on commit 3f609b2

Please sign in to comment.