Use onError function when parsing ints to avoid exception handling

Based on the discussion https://github.com/davecom/chess.dart/commit/7753babf8fd2ae8cb3e68c89db15c7d863db0710#commitcomment-6961659