add better error reporting for Overflows

This commit is contained in:
Mamy André-Ratsimbazafy 2019-06-26 14:04:10 +02:00
parent d44da85c86
commit 56a01bb210
No known key found for this signature in database
GPG Key ID: 7B88AD1FE79492E1
1 changed files with 10 additions and 4 deletions

View File

@ -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