From 32532595576c45ade31105b807b70e12be9d937e Mon Sep 17 00:00:00 2001 From: Richard Carlsson Date: Wed, 27 Jan 2021 19:10:48 +0100 Subject: Quote source as part of error messages Can be suppressed with the 'brief' compiler option. Moves message formatting code to a separate module. --- lib/compiler/src/compile.erl | 34 ++++------------------------------ 1 file changed, 4 insertions(+), 30 deletions(-) (limited to 'lib/compiler/src/compile.erl') diff --git a/lib/compiler/src/compile.erl b/lib/compiler/src/compile.erl index 29ad2afb38..d4968ebb71 100644 --- a/lib/compiler/src/compile.erl +++ b/lib/compiler/src/compile.erl @@ -1781,8 +1781,8 @@ write_binary(Name, Bin, St) -> report_errors(#compile{options=Opts,errors=Errors}) -> case member(report_errors, Opts) of true -> - foreach(fun ({{F,_L},Eds}) -> list_errors(F, Eds); - ({F,Eds}) -> list_errors(F, Eds) end, + foreach(fun ({{F,_L},Eds}) -> sys_messages:list_errors(F, Eds, Opts); + ({F,Eds}) -> sys_messages:list_errors(F, Eds, Opts) end, Errors); false -> ok end. @@ -1796,40 +1796,14 @@ report_warnings(#compile{options=Opts,warnings=Ws0}) -> ReportWerror = Werror andalso member(report_errors, Opts), case member(report_warnings, Opts) orelse ReportWerror of true -> - Ws1 = flatmap(fun({{F,_L},Eds}) -> format_message(F, P, Eds); - ({F,Eds}) -> format_message(F, P, Eds) end, + Ws1 = flatmap(fun({{F,_L},Eds}) -> sys_messages:format_messages(F, P, Eds, Opts); + ({F,Eds}) -> sys_messages:format_messages(F, P, Eds, Opts) end, Ws0), Ws = lists:sort(Ws1), foreach(fun({_,Str}) -> io:put_chars(Str) end, Ws); false -> ok end. -format_message(F, P, [{none,Mod,E}|Es]) -> - M = {none,io_lib:format("~ts: ~s~ts\n", [F,P,Mod:format_error(E)])}, - [M|format_message(F, P, Es)]; -format_message(F, P, [{{Line,Column}=Loc,Mod,E}|Es]) -> - M = {{F,Loc},io_lib:format("~ts:~w:~w: ~s~ts\n", - [F,Line,Column,P,Mod:format_error(E)])}, - [M|format_message(F, P, Es)]; -format_message(F, P, [{Line,Mod,E}|Es]) -> - M = {{F,{Line,0}},io_lib:format("~ts:~w: ~s~ts\n", - [F,Line,P,Mod:format_error(E)])}, - [M|format_message(F, P, Es)]; -format_message(_, _, []) -> []. - -%% list_errors(File, ErrorDescriptors) -> ok - -list_errors(F, [{none,Mod,E}|Es]) -> - io:fwrite("~ts: ~ts\n", [F,Mod:format_error(E)]), - list_errors(F, Es); -list_errors(F, [{{Line,Column},Mod,E}|Es]) -> - io:fwrite("~ts:~w:~w: ~ts\n", [F,Line,Column,Mod:format_error(E)]), - list_errors(F, Es); -list_errors(F, [{Line,Mod,E}|Es]) -> - io:fwrite("~ts:~w: ~ts\n", [F,Line,Mod:format_error(E)]), - list_errors(F, Es); -list_errors(_F, []) -> ok. - %% erlfile(Dir, Base) -> ErlFile %% outfile(Base, Extension, Options) -> OutputFile %% objfile(Base, Target, Options) -> ObjFile -- cgit v1.2.1