diff options
author | Eduardo Julian | 2019-04-15 23:34:11 -0400 |
---|---|---|
committer | Eduardo Julian | 2019-04-15 23:34:11 -0400 |
commit | d3b8919e3609243191c0d946aa0ddb68fc20ff69 (patch) | |
tree | 89aaceaddf6b5dc29b8c09279d83e1889b7a44c5 /stdlib/source | |
parent | 8e86ccf0c3d01d44c4dfa662569c74f2eb80e8d4 (diff) |
Yet more improvements to error messaging.
Diffstat (limited to 'stdlib/source')
-rw-r--r-- | stdlib/source/lux/control/exception.lux | 15 | ||||
-rw-r--r-- | stdlib/source/lux/tool/compiler/phase/analysis/function.lux | 4 |
2 files changed, 14 insertions, 5 deletions
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)) |