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"]]
This commit is contained in:
Serge Aleynikov 2012-10-17 10:16:55 -04:00
parent 38902e9a52
commit b606e3bfc5

View file

@ -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")).