From 79881757fb924ce1e776f3d8e429eb3e0e185d18 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sat, 15 Dec 2018 15:15:03 -0800 Subject: [PATCH] Truncating super long error messages. --- pretty_errors.lua | 4 ++++ pretty_errors.moon | 3 +++ 2 files changed, 7 insertions(+) diff --git a/pretty_errors.lua b/pretty_errors.lua index f5de557..afb1793 100644 --- a/pretty_errors.lua +++ b/pretty_errors.lua @@ -58,6 +58,10 @@ format_error = function(err) end end end + if i > err_linenum + 1 + 5 then + err_msg = err_msg .. "\n ...\n" + break + end end end local box_width = 70 diff --git a/pretty_errors.moon b/pretty_errors.moon index 578aab6..dcffae2 100644 --- a/pretty_errors.moon +++ b/pretty_errors.moon @@ -45,6 +45,9 @@ format_error = (err)-> err_msg ..= "\n\027[2m#{fmt_str\format(i)}\027[0;41;30m#{during}\027[0m#{after}" else err_msg ..= "\n\027[2m#{fmt_str\format(i)}\027[0;41;30m#{line}\027[0m" + if i > err_linenum+1 + 5 + err_msg ..= "\n ...\n" + break box_width = 70 err_text = "\027[47;31;1m#{string2.wrap(" "..err.error, box_width, 16)\gsub("\n", "\n\027[47;31;1m ")}"