Removed utf8 pointer characters from error messages to better support
consoles without utf8 support (may change this back later). Also increased contrast of error messages (no longer assuming user has a sane color palette).
This commit is contained in:
parent
a7339001d2
commit
1ff4e4d432
@ -19,13 +19,8 @@ format_error = function(err)
|
|||||||
local err_size = math.min((err.stop - err.start), (#err_line - err_linepos) + 1)
|
local err_size = math.min((err.stop - err.start), (#err_line - err_linepos) + 1)
|
||||||
local nl_indicator = (err_linepos > #err_line) and " " or ""
|
local nl_indicator = (err_linepos > #err_line) and " " or ""
|
||||||
local fmt_str = " %" .. tostring(#tostring(err_linenum + context)) .. "d|"
|
local fmt_str = " %" .. tostring(#tostring(err_linenum + context)) .. "d|"
|
||||||
local pointer
|
local pointer = (" "):rep(err_linepos + #fmt_str:format(0) - 1) .. ("^"):rep(err_size)
|
||||||
if err_size >= 2 then
|
local err_msg = "\027[31;1m" .. tostring(err.title or "Error") .. " at " .. tostring(err.filename or '???') .. ":" .. tostring(err_linenum) .. "," .. tostring(err_linepos) .. "\027[0m"
|
||||||
pointer = (" "):rep(err_linepos + #fmt_str:format(0) - 1) .. "╚" .. tostring(("═"):rep(err_size - 2)) .. "╝"
|
|
||||||
else
|
|
||||||
pointer = (" "):rep(err_linepos + #fmt_str:format(0) - 1) .. "⬆"
|
|
||||||
end
|
|
||||||
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"
|
|
||||||
local lines = err.source:lines()
|
local lines = err.source:lines()
|
||||||
for i = err_linenum - context, err_linenum - 1 do
|
for i = err_linenum - context, err_linenum - 1 do
|
||||||
do
|
do
|
||||||
@ -66,9 +61,9 @@ format_error = function(err)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
local box_width = 70
|
local box_width = 70
|
||||||
local err_text = "\027[47;31;1m" .. tostring(" " .. err.error:wrapped_to(box_width, 16):gsub("\n", "\n\027[47;31;1m "))
|
local err_text = "\027[47;30;1m" .. tostring(" " .. err.error:wrapped_to(box_width, 16):gsub("\n", "\n\027[47;30;1m "))
|
||||||
if err.hint then
|
if err.hint then
|
||||||
err_text = err_text .. "\n\027[47;30m" .. tostring((" Suggestion: " .. tostring(err.hint)):wrapped_to(box_width, 16):gsub("\n", "\n\027[47;30m "))
|
err_text = err_text .. "\n\027[47;30;3m" .. tostring((" Suggestion: " .. tostring(err.hint)):wrapped_to(box_width, 16):gsub("\n", "\n\027[47;30;3m "))
|
||||||
end
|
end
|
||||||
err_msg = err_msg .. ("\n\027[33;1m " .. box(err_text):gsub("\n", "\n "))
|
err_msg = err_msg .. ("\n\027[33;1m " .. box(err_text):gsub("\n", "\n "))
|
||||||
for i = err_linenum_end + 1, err_linenum_end + context do
|
for i = err_linenum_end + 1, err_linenum_end + context do
|
||||||
|
@ -19,11 +19,14 @@ format_error = (err)->
|
|||||||
err_size = math.min((err.stop - err.start), (#err_line-err_linepos) + 1)
|
err_size = math.min((err.stop - err.start), (#err_line-err_linepos) + 1)
|
||||||
nl_indicator = (err_linepos > #err_line) and " " or ""
|
nl_indicator = (err_linepos > #err_line) and " " or ""
|
||||||
fmt_str = " %#{#tostring(err_linenum+context)}d|"
|
fmt_str = " %#{#tostring(err_linenum+context)}d|"
|
||||||
pointer = if err_size >= 2
|
|
||||||
(" ")\rep(err_linepos+#fmt_str\format(0)-1).."╚#{("═")\rep(err_size-2)}╝"
|
pointer = (" ")\rep(err_linepos+#fmt_str\format(0)-1)..("^")\rep(err_size)
|
||||||
else
|
--pointer = if err_size >= 2
|
||||||
(" ")\rep(err_linepos+#fmt_str\format(0)-1).."⬆"
|
-- (" ")\rep(err_linepos+#fmt_str\format(0)-1).."╚#{("═")\rep(err_size-2)}╝"
|
||||||
err_msg = "\027[33;41;1m#{err.title or "Error"} at #{err.filename or '???'}:#{err_linenum},#{err_linepos}\027[0m"
|
--else
|
||||||
|
-- (" ")\rep(err_linepos+#fmt_str\format(0)-1).."⬆"
|
||||||
|
|
||||||
|
err_msg = "\027[31;1m#{err.title or "Error"} at #{err.filename or '???'}:#{err_linenum},#{err_linepos}\027[0m"
|
||||||
lines = err.source\lines!
|
lines = err.source\lines!
|
||||||
for i=err_linenum-context,err_linenum-1
|
for i=err_linenum-context,err_linenum-1
|
||||||
if line = lines[i]
|
if line = lines[i]
|
||||||
@ -51,9 +54,9 @@ format_error = (err)->
|
|||||||
break
|
break
|
||||||
|
|
||||||
box_width = 70
|
box_width = 70
|
||||||
err_text = "\027[47;31;1m#{" "..err.error\wrapped_to(box_width, 16)\gsub("\n", "\n\027[47;31;1m ")}"
|
err_text = "\027[47;30;1m#{" "..err.error\wrapped_to(box_width, 16)\gsub("\n", "\n\027[47;30;1m ")}"
|
||||||
if err.hint
|
if err.hint
|
||||||
err_text ..= "\n\027[47;30m#{(" Suggestion: #{err.hint}")\wrapped_to(box_width, 16)\gsub("\n", "\n\027[47;30m ")}"
|
err_text ..= "\n\027[47;30;3m#{(" Suggestion: #{err.hint}")\wrapped_to(box_width, 16)\gsub("\n", "\n\027[47;30;3m ")}"
|
||||||
err_msg ..= "\n\027[33;1m "..box(err_text)\gsub("\n", "\n ")
|
err_msg ..= "\n\027[33;1m "..box(err_text)\gsub("\n", "\n ")
|
||||||
|
|
||||||
for i=err_linenum_end+1,err_linenum_end+context
|
for i=err_linenum_end+1,err_linenum_end+context
|
||||||
|
Loading…
Reference in New Issue
Block a user