bhlangonijr / chesslib

chess library for legal move generation, FEN/PGN parsing and more
Apache License 2.0
229 stars 80 forks source link

Exception is thrown for invalid time control tag #72

Closed Oziomajnr closed 2 years ago

Oziomajnr commented 3 years ago

When the time control tag is invalid, a PGN exception is thrown

https://github.com/bhlangonijr/chesslib/blob/25435a6107292e3b75a9b57f91a40548b7058dca/src/main/java/com/github/bhlangonijr/chesslib/pgn/GameLoader.java#L162

Is this a good reason to break the whole PGN parsing process? The logic for parsing the time control tag allows that the time control tag could be absent and in that case the time control is not parsed along with the PGN, I think the same thing should happen when there is an error with parsing the time control, the library could assume its absent and not parse it.

There are a lot of apps these days with invalid time control tags like chess.com.

I would like to know what you think about this.

bhlangonijr commented 3 years ago

Hey @Oziomajnr , I agree with you. Instead of throwing the exception it can just log a warning message. I'll add this change in the next release.

Thank you