Skip to content

Commit

Permalink
fix: reraise KeyAlreadyPresent as ParseError (#208)
Browse files Browse the repository at this point in the history
  • Loading branch information
frostming committed Jul 4, 2022
1 parent 8cccd02 commit 296be14
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Expand Up @@ -5,6 +5,9 @@
### Fixed

- Fix `unwrap()` for String values to remove the quotes. ([#199](https://github.com/sdispater/tomlkit/issues/199))
- Make `KeyAlreadyPresent` and `InvalidStringError` subclasses of `ParseError`. ([#202](https://github.com/sdispater/tomlkit/issues/202))
- Remove empty table from `OutOfOrderTableProxy` when deleting items. ([#204](https://github.com/sdispater/tomlkit/issues/204))
- Raise errors when trying to access unsupported methods on `OutOfOrderTableProxy`. ([#205](https://github.com/sdispater/tomlkit/issues/205))

## [0.11.0] - 2022-05-24

Expand Down
10 changes: 8 additions & 2 deletions tomlkit/parser.py
Expand Up @@ -146,7 +146,10 @@ def parse(self) -> TOMLDocument:
key, value = item
if (key is not None and key.is_multi()) or not self._merge_ws(value, body):
# We actually have a table
body.append(key, value)
try:
body.append(key, value)
except Exception as e:
raise self.parse_error(ParseError, str(e)) from e

self.mark()

Expand All @@ -157,7 +160,10 @@ def parse(self) -> TOMLDocument:
# along with it.
value = self._parse_aot(value, key)

body.append(key, value)
try:
body.append(key, value)
except Exception as e:
raise self.parse_error(ParseError, str(e)) from e

body.parsing(False)

Expand Down

0 comments on commit 296be14

Please sign in to comment.