diff options
author | Tuncer Ayaz <tuncer.ayaz@gmail.com> | 2012-06-05 21:02:14 +0200 |
---|---|---|
committer | Tuncer Ayaz <tuncer.ayaz@gmail.com> | 2012-06-11 19:42:00 +0200 |
commit | 8a2274b8b4b060c3de03db682796b48d903804e2 (patch) | |
tree | 23192d16ee92b5a8db201d036afafca804b1a7df /src/rebar_base_compiler.erl | |
parent | 0716cf708ca3d3d61d2435b88e6d68410a49db6e (diff) |
Refactor shared error reporting code
Diffstat (limited to 'src/rebar_base_compiler.erl')
-rw-r--r-- | src/rebar_base_compiler.erl | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/src/rebar_base_compiler.erl b/src/rebar_base_compiler.erl index dacb44d..6167e0e 100644 --- a/src/rebar_base_compiler.erl +++ b/src/rebar_base_compiler.erl @@ -29,7 +29,7 @@ -include("rebar.hrl"). -export([run/4, run/7, run/8, - format_errors/2, format_warnings/2, format_warnings/3]). + ok_tuple/2, error_tuple/4]). %% =================================================================== @@ -80,18 +80,11 @@ run(Config, FirstFiles, SourceDir, SourceExt, TargetDir, TargetExt, simple_compile_wrapper(S, Target, Compile3Fn, C, CheckLastMod) end). -format_errors(Source, Errors) -> - format_errors(Source, "", Errors). - -format_warnings(Source, Warnings) -> - format_warnings(Source, Warnings, []). +ok_tuple(Source, Ws) -> + {ok, format_warnings(Source, Ws)}. -format_warnings(Source, Warnings, Opts) -> - Prefix = case lists:member(warnings_as_errors, Opts) of - true -> ""; - false -> "Warning: " - end, - format_errors(Source, Prefix, Warnings). +error_tuple(Source, Es, Ws, Opts) -> + {error, format_errors(Source, Es), format_warnings(Source, Ws, Opts)}. %% =================================================================== %% Internal functions @@ -218,6 +211,19 @@ compile_worker(QueuePid, Config, CompileFn) -> ok end. +format_errors(Source, Errors) -> + format_errors(Source, "", Errors). + +format_warnings(Source, Warnings) -> + format_warnings(Source, Warnings, []). + +format_warnings(Source, Warnings, Opts) -> + Prefix = case lists:member(warnings_as_errors, Opts) of + true -> ""; + false -> "Warning: " + end, + format_errors(Source, Prefix, Warnings). + maybe_report([{error, {error, _Es, _Ws}=ErrorsAndWarnings}, {source, _}]) -> maybe_report(ErrorsAndWarnings); maybe_report({error, Es, Ws}) -> |