summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFred Hebert <mononcqc@ferd.ca>2018-08-02 19:43:57 -0400
committerFred Hebert <mononcqc@ferd.ca>2018-08-03 20:37:53 -0400
commite157b6c23fcf86e76a87edf38283d5684df1307f (patch)
tree6724477fa75aff85b4a8f478d43aa6ec3d54fb6f
parent608a1aa865a7cff6ea4c263d38ec34c21b82c8fa (diff)
Friendlier output on include_lib errors
Turns output like this: ===> Compiling apps/c/src/c.erl failed apps/c/src/c.erl:3: can't find include lib "parse_trans/include/codegen.hrl" Into: ===> Compiling apps/c/src/c.erl failed apps/c/src/c.erl:3: can't find include lib "parse_trans/include/codegen.hrl"; Make sure parse_trans is in your app file's 'applications' list Which is likely going to help newcomers encountering issues.
-rw-r--r--src/rebar_base_compiler.erl16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/rebar_base_compiler.erl b/src/rebar_base_compiler.erl
index 3f273f1..00b0533 100644
--- a/src/rebar_base_compiler.erl
+++ b/src/rebar_base_compiler.erl
@@ -264,14 +264,24 @@ report(Messages) ->
-spec format_errors(_, Extra, [err_or_warn()]) -> [string()] when
Extra :: string().
format_errors(_MainSource, Extra, Errors) ->
- [begin
- [format_error(Source, Extra, Desc) || Desc <- Descs]
- end
+ [[format_error(Source, Extra, Desc) || Desc <- Descs]
|| {Source, Descs} <- Errors].
%% @private format compiler errors into proper outputtable strings
-spec format_error(file:filename(), Extra, err_or_warn()) -> string() when
Extra :: string().
+format_error(Source, Extra, {Line, Mod=epp, Desc={include,lib,File}}) ->
+ %% Special case for include file errors, overtaking the default one
+ BaseDesc = Mod:format_error(Desc),
+ Friendly = case filename:split(File) of
+ [Lib, "include", _] ->
+ io_lib:format("; Make sure ~s is in your app "
+ "file's 'applications' list", [Lib]);
+ _ ->
+ ""
+ end,
+ FriendlyDesc = BaseDesc ++ Friendly,
+ ?FMT("~ts:~w: ~ts~ts~n", [Source, Line, Extra, FriendlyDesc]);
format_error(Source, Extra, {{Line, Column}, Mod, Desc}) ->
ErrorDesc = Mod:format_error(Desc),
?FMT("~ts:~w:~w: ~ts~ts~n", [Source, Line, Column, Extra, ErrorDesc]);