Skip to content

Commit

Permalink
Improve chess.pgn error logs (closes #961)
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasf committed Feb 24, 2023
1 parent 3439cb6 commit ac29457
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions chess/pgn.py
Original file line number Diff line number Diff line change
Expand Up @@ -872,12 +872,13 @@ def builder(cls: Type[GameT]) -> GameBuilder[GameT]:
return GameBuilder(Game=cls)

def __repr__(self) -> str:
return "<{} at {:#x} ({!r} vs. {!r}, {!r}{})>".format(
return "<{} at {:#x} ({!r} vs. {!r}, {!r} at {!r}{})>".format(
type(self).__name__,
id(self),
self.headers.get("White", "?"),
self.headers.get("Black", "?"),
self.headers.get("Date", "????.??.??"),
self.headers.get("Site", "?"),
f", {len(self.errors)} errors" if self.errors else "")


Expand Down Expand Up @@ -1202,7 +1203,7 @@ def handle_error(self, error: Exception) -> None:
>>>
>>> game = chess.pgn.read_game(pgn, Visitor=MyGameBuilder)
"""
LOGGER.exception("error during pgn parsing")
LOGGER.error("%s while parsing %r", error, self.game)
self.game.errors.append(error)

def result(self) -> GameT:
Expand Down

0 comments on commit ac29457

Please sign in to comment.