summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSerge Aleynikov <saleyn@gmail.com>2012-10-17 10:16:55 -0400
committerSerge Aleynikov <saleyn@gmail.com>2012-10-22 08:55:30 +0400
commitb606e3bfc54b48eb28fd7e0a9e5fae913a4e24c3 (patch)
tree03424d8d103d241f1b6c5233a6d6bfa561e19732
parent38902e9a5247f46a182e72d78d6ad5daf975f2a4 (diff)
Made more readable printout of the erlydtl compiler message
The printed message is made more terse. Example before applying patch: ERROR: Compiling template src/view/test.dtl failed: {error,{"src/view/test.dtl", [{{4,7}, erlydtl_parser, ["syntax error before: ",["\"\\\"HELLO_WORLD\\\"\""]]}]}} Example after applying patch: ERROR: Compiling template "src/cmp_html_error_template.dtl" failed: (line:3, col:12): ["syntax error before: ",["trans"]]
-rw-r--r--src/rebar_erlydtl_compiler.erl6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/rebar_erlydtl_compiler.erl b/src/rebar_erlydtl_compiler.erl
index 0607ded..23ea41c 100644
--- a/src/rebar_erlydtl_compiler.erl
+++ b/src/rebar_erlydtl_compiler.erl
@@ -190,12 +190,18 @@ do_compile(Source, Target, DtlOpts) ->
module_name(Target),
Opts) of
ok -> ok;
+ {error, {File, [{Pos, _Mod, Err}]}} ->
+ ?ERROR("Compiling template ~p failed:~n (~s): ~p~n",
+ [File, err_location(Pos), Err]);
Reason ->
?ERROR("Compiling template ~s failed:~n ~p~n",
[Source, Reason]),
?FAIL
end.
+err_location({L,C}) -> io_lib:format("line:~w, col:~w", [L, C]);
+err_location(L) -> io_lib:format("line:~w", [L]).
+
module_name(Target) ->
F = filename:basename(Target),
string:substr(F, 1, length(F)-length(".beam")).