From 56a01bb210dcb819f764c829dba9e64713237f10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mamy=20Andr=C3=A9-Ratsimbazafy?= Date: Wed, 26 Jun 2019 14:04:10 +0200 Subject: [PATCH] add better error reporting for Overflows --- fixtures_utils.nim | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/fixtures_utils.nim b/fixtures_utils.nim index a4b51a2..af10cd7 100644 --- a/fixtures_utils.nim +++ b/fixtures_utils.nim @@ -18,13 +18,19 @@ proc yamlToJson*(file: string): seq[JsonNode] = try: let fs = openFileStream(file) defer: fs.close() - result = fs.loadToJson() + try: + result = fs.loadToJson() + except OverflowError as e: + echo "Overflow exception when parsing. Did you stringify 18446744073709551615 (-1)?" + echo "Current file: ", file + echo "Current position: ", fs.getPosition() + var line: string + discard fs.peekLine(line) + echo "Peek at the line: ", line + raise except IOError: echo "Exception when reading file: " & file raise - except OverflowError: - echo "Overflow exception when parsing. Did you stringify 18446744073709551615 (-1)?" - raise when isMainModule: # Do not forget to stringify FAR_EPOCH_SLOT = 18446744073709551615 (-1) in the YAML file