diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2018-09-16 17:38:19 -0700 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2018-09-16 17:38:51 -0700 |
| commit | f225a48367ca7b3e188bd34377f730370851e804 (patch) | |
| tree | 590086751802815906fcb9c9aa416359880aa6e7 /pretty_errors.lua | |
| parent | 96e5e567cb208194793a56462b90fb02c9cfe927 (diff) | |
Much better error reporting for compile errors (i.e. not parse errors),
using the pretty_error system.
Diffstat (limited to 'pretty_errors.lua')
| -rw-r--r-- | pretty_errors.lua | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/pretty_errors.lua b/pretty_errors.lua index 041c3d1..f5de557 100644 --- a/pretty_errors.lua +++ b/pretty_errors.lua @@ -25,7 +25,7 @@ format_error = function(err) else pointer = (" "):rep(err_linepos + #fmt_str:format(0) - 1) .. "⬆" end - local err_msg = "\027[33;41;1mParse 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) .. "\027[0m" for i = err_linenum - context, err_linenum - 1 do do local line = string2.line(err.source, i) @@ -61,9 +61,9 @@ format_error = function(err) end end local box_width = 70 - local err_text = "\027[47;31;1m" .. tostring((" " .. err.error):wrap_to_1(box_width):gsub("\n", "\n\027[47;31;1m ")) + local err_text = "\027[47;31;1m" .. tostring(string2.wrap(" " .. err.error, box_width, 16):gsub("\n", "\n\027[47;31;1m ")) if err.hint then - err_text = err_text .. "\n\027[47;30m" .. tostring((" Suggestion: " .. tostring(err.hint)):wrap_to_1(box_width):gsub("\n", "\n\027[47;30m ")) + err_text = err_text .. "\n\027[47;30m" .. tostring(string2.wrap(" Suggestion: " .. tostring(err.hint), box_width, 16):gsub("\n", "\n\027[47;30m ")) 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 |
