Skip to content

Commit d2aaf6d

Browse files
author
Shashi Gowda
committed
store error location string instead of the whole string in CSVParseError - fixes #27
1 parent f33672c commit d2aaf6d

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/csv.jl

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -399,23 +399,26 @@ end
399399

400400
immutable CSVParseError <: Exception
401401
err_code
402-
str
402+
location_display
403403
rec
404404
lineno
405405
rowno
406406
colno
407407
pos
408408
fieldpos
409+
charinline
409410
end
410411

411-
function Base.showerror(io::IO, err::CSVParseError)
412-
str = err.str
413-
pos = err.pos
414-
412+
function CSVParseError(e_code, str, rec, lineno, rowno, colno, pos, fieldpos)
415413
rng = getlineat(str, pos)
416-
charinline = err.pos - first(rng)
417-
err = "Parse error at line $(err.lineno) at char $charinline:\n" *
418-
showerrorchar(str, pos, 100) *
414+
charinline = pos - first(rng)
415+
CSVParseError(e_code, showerrorchar(str, pos, 100), rec, lineno, rowno, colno, pos, fieldpos, charinline)
416+
end
417+
418+
419+
function Base.showerror(io::IO, err::CSVParseError)
420+
err = "Parse error at line $(err.lineno) at char $(err.charinline):\n" *
421+
err.location_display *
419422
"\nCSV column $(err.colno) is expected to be: " *
420423
string(err.rec.fields[err.colno])
421424
print(io, err)

0 commit comments

Comments
 (0)