aboutsummaryrefslogtreecommitdiff
path: root/pretty_errors.lua
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2019-01-27 02:07:37 -0800
committerBruce Hill <bruce@bruce-hill.com>2019-01-27 02:08:47 -0800
commit1ff4e4d432b17110ff6ba4feb54d00128106ece0 (patch)
tree909f85b17ee5325f0284e23f9d5acceedb129368 /pretty_errors.lua
parenta7339001d2e93c3fb2a957ab782f47d46657619a (diff)
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).
Diffstat (limited to 'pretty_errors.lua')
-rw-r--r--pretty_errors.lua13
1 files changed, 4 insertions, 9 deletions
diff --git a/pretty_errors.lua b/pretty_errors.lua
index 6a248d1..ecc6cd2 100644
--- a/pretty_errors.lua
+++ b/pretty_errors.lua
@@ -19,13 +19,8 @@ format_error = function(err)
local err_size = math.min((err.stop - err.start), (#err_line - err_linepos) + 1)
local nl_indicator = (err_linepos > #err_line) and " " or ""
local fmt_str = " %" .. tostring(#tostring(err_linenum + context)) .. "d|"
- local pointer
- if err_size >= 2 then
- 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 pointer = (" "):rep(err_linepos + #fmt_str:format(0) - 1) .. ("^"):rep(err_size)
+ local err_msg = "\027[31;1m" .. tostring(err.title or "Error") .. " at " .. tostring(err.filename or '???') .. ":" .. tostring(err_linenum) .. "," .. tostring(err_linepos) .. "\027[0m"
local lines = err.source:lines()
for i = err_linenum - context, err_linenum - 1 do
do
@@ -66,9 +61,9 @@ format_error = function(err)
end
end
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
- 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
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