From b606e3bfc54b48eb28fd7e0a9e5fae913a4e24c3 Mon Sep 17 00:00:00 2001 From: Serge Aleynikov Date: Wed, 17 Oct 2012 10:16:55 -0400 Subject: 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"]] --- src/rebar_erlydtl_compiler.erl | 6 ++++++ 1 file changed, 6 insertions(+) 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")). -- cgit v1.1