The error will be thrown because wrong CSV row accessed, but the error won't be catched by try block. Why, and how to catch it?
import parsecsv
# Prepare a file
let content = """One,Two,Three,Four
1,2,3,4
10,20,30,40
100,200,300,400
"""
writeFile("temp.csv", content)
var p: CsvParser
p.open("temp.csv")
p.readHeaderRow()
while p.readRow():
try:
echo p.rowEntry("wrong") # <= Error here
except:
echo "error"
p.close()
The error
$ nim c -r run.nim
Traceback (most recent call last)
/alex/projects/run.nim(33) run
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
Error: execution of an external program failed: '/alex/projects/run '