Skip to content

Commit

Permalink
stubber: Handle errors while reading pyproject.toml
Browse files Browse the repository at this point in the history
Signed-off-by: Jos Verlinde <Jos.Verlinde@microsoft.com>
  • Loading branch information
Josverl committed Jan 1, 2025
1 parent cfcf260 commit fca6c6c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/stubber/publish/stubpackage.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,12 @@ def pyproject(self) -> Union[Dict[str, Any], None]:
pyproject = None
_toml = self.toml_path
if (_toml).exists():
with open(_toml, "rb") as f:
pyproject = tomllib.load(f)
log.info(f"Load pyproject from {_toml}")
try:
with open(_toml, "rb") as f:
pyproject = tomllib.load(f)
except tomllib.TOMLDecodeError as e:
log.error(f"Could not load pyproject.toml file {e}")
return pyproject

@pyproject.setter
Expand Down

0 comments on commit fca6c6c

Please sign in to comment.