Added error line column to error messages.

This commit is contained in:
Bruce Hill 2019-01-19 19:38:12 -08:00
parent 6ffd38b511
commit 0538b869be
2 changed files with 2 additions and 2 deletions

View File

@ -25,7 +25,7 @@ format_error = function(err)
else else
pointer = (" "):rep(err_linepos + #fmt_str:format(0) - 1) .. "" pointer = (" "):rep(err_linepos + #fmt_str:format(0) - 1) .. ""
end end
local err_msg = "\027[33;41;1m" .. tostring(err.title or "Error") .. " at " .. tostring(err.filename or '???') .. ":" .. tostring(err_linenum) .. "\027[0m" local err_msg = "\027[33;41;1m" .. tostring(err.title or "Error") .. " at " .. tostring(err.filename or '???') .. ":" .. tostring(err_linenum) .. "," .. tostring(err_linepos) .. "\027[0m"
for i = err_linenum - context, err_linenum - 1 do for i = err_linenum - context, err_linenum - 1 do
do do
local line = string2.line(err.source, i) local line = string2.line(err.source, i)

View File

@ -23,7 +23,7 @@ format_error = (err)->
(" ")\rep(err_linepos+#fmt_str\format(0)-1).."╚#{("═")\rep(err_size-2)}╝" (" ")\rep(err_linepos+#fmt_str\format(0)-1).."╚#{("═")\rep(err_size-2)}╝"
else else
(" ")\rep(err_linepos+#fmt_str\format(0)-1).."⬆" (" ")\rep(err_linepos+#fmt_str\format(0)-1).."⬆"
err_msg = "\027[33;41;1m#{err.title or "Error"} at #{err.filename or '???'}:#{err_linenum}\027[0m" err_msg = "\027[33;41;1m#{err.title or "Error"} at #{err.filename or '???'}:#{err_linenum},#{err_linepos}\027[0m"
for i=err_linenum-context,err_linenum-1 for i=err_linenum-context,err_linenum-1
if line = string2.line(err.source, i) if line = string2.line(err.source, i)
err_msg ..= "\n\027[2m#{fmt_str\format(i)}\027[0m#{line}\027[0m" err_msg ..= "\n\027[2m#{fmt_str\format(i)}\027[0m#{line}\027[0m"