From d3b8919e3609243191c0d946aa0ddb68fc20ff69 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Mon, 15 Apr 2019 23:34:11 -0400 Subject: Yet more improvements to error messaging. --- stdlib/source/lux/control/exception.lux | 15 ++++++++++++--- .../source/lux/tool/compiler/phase/analysis/function.lux | 4 ++-- 2 files changed, 14 insertions(+), 5 deletions(-) (limited to 'stdlib') diff --git a/stdlib/source/lux/control/exception.lux b/stdlib/source/lux/control/exception.lux index 5d241b0c6..cc8635b13 100644 --- a/stdlib/source/lux/control/exception.lux +++ b/stdlib/source/lux/control/exception.lux @@ -109,18 +109,27 @@ (~ (maybe.default (' "") body))))}))))) ))) +(def: header-separator ": ") + (def: #export (report' entries) (-> (List [Text Text]) Text) (let [largest-header-size (|> entries (list@map (|>> product.left text.size)) - (list@fold n/max 0))] + (list@fold n/max 0)) + on-new-line (|> " " + (list.repeat (n/+ (text.size header-separator) + largest-header-size)) + (text.join-with "") + (text@compose text.new-line))] (|> entries (list@map (function (_ [header message]) (let [padding (|> " " (list.repeat (n/- (text.size header) largest-header-size)) (text.join-with ""))] - ($_ text@compose padding header ": " message)))) + (|> message + (text.replace-all text.new-line on-new-line) + ($_ text@compose padding header ..header-separator))))) (text.join-with text.new-line)))) (syntax: #export (report {entries (p.many (s.tuple (p.and s.any s.any)))}) @@ -131,7 +140,7 @@ (def: separator ($_ "lux text concat" text.new-line text.new-line - "----------------------------------------------------------------" + (|> "-" (list.repeat 64) (text.join-with "")) text.new-line text.new-line)) (def: #export (decorate prelude error) diff --git a/stdlib/source/lux/tool/compiler/phase/analysis/function.lux b/stdlib/source/lux/tool/compiler/phase/analysis/function.lux index fbaaf2fc5..76effa0dc 100644 --- a/stdlib/source/lux/tool/compiler/phase/analysis/function.lux +++ b/stdlib/source/lux/tool/compiler/phase/analysis/function.lux @@ -34,8 +34,8 @@ ["Arguments" (|> arguments list.enumerate (list@map (.function (_ [idx argC]) - (format text.new-line " " (%n idx) " " (%code argC)))) - (text.join-with ""))])) + (format (%n idx) " " (%code argC)))) + (text.join-with text.new-line))])) (def: #export (function analyse function-name arg-name body) (-> Phase Text Text Code (Operation Analysis)) -- cgit v1.2.3