couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject [06/50] git commit: Always return the errors and warnings from erlydtl
Date Fri, 17 Jan 2014 23:12:51 GMT
Always return the errors and warnings from erlydtl

This allows us to use `rebar_base_compiler:ok_tuple/3` and
`rebar_base_compiler:error_tuple/5` when returning from
`rebar_erlydtl_compiler`.


Project: http://git-wip-us.apache.org/repos/asf/couchdb-rebar/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-rebar/commit/daed79f6
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-rebar/tree/daed79f6
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-rebar/diff/daed79f6

Branch: refs/heads/import
Commit: daed79f62925c0e4dd71f812f2283873a2720b91
Parents: e840ac2
Author: Anthony Ramine <n.oxyde@gmail.com>
Authored: Sat Dec 8 11:25:29 2012 +0100
Committer: Tuncer Ayaz <tuncer.ayaz@gmail.com>
Committed: Fri Sep 20 20:54:54 2013 +0200

----------------------------------------------------------------------
 src/rebar_erlydtl_compiler.erl | 32 +++++++++++++++-----------------
 1 file changed, 15 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-rebar/blob/daed79f6/src/rebar_erlydtl_compiler.erl
----------------------------------------------------------------------
diff --git a/src/rebar_erlydtl_compiler.erl b/src/rebar_erlydtl_compiler.erl
index 4449be6..6172879 100644
--- a/src/rebar_erlydtl_compiler.erl
+++ b/src/rebar_erlydtl_compiler.erl
@@ -116,8 +116,8 @@ compile(Config, _AppFile) ->
                                      option(source_ext, DtlOpts),
                                      option(out_dir, DtlOpts),
                                      option(module_ext, DtlOpts) ++ ".beam",
-                                     fun(S, T, _C) ->
-                                        compile_dtl(S, T, DtlOpts)
+                                     fun(S, T, C) ->
+                                        compile_dtl(C, S, T, DtlOpts)
                                      end,
                                      [{check_last_mod, false},
                                       {recursive, option(recursive, DtlOpts)}])
@@ -169,10 +169,10 @@ default(out_dir)  -> "ebin";
 default(source_ext) -> ".dtl";
 default(module_ext) -> "_dtl";
 default(custom_tags_dir) -> "";
-default(compiler_options) -> [report, return];
+default(compiler_options) -> [return];
 default(recursive) -> true.
 
-compile_dtl(Source, Target, DtlOpts) ->
+compile_dtl(Config, Source, Target, DtlOpts) ->
     case code:which(erlydtl) of
         non_existing ->
             ?ERROR("~n===============================================~n"
@@ -185,13 +185,13 @@ compile_dtl(Source, Target, DtlOpts) ->
         _ ->
             case needs_compile(Source, Target, DtlOpts) of
                 true ->
-                    do_compile(Source, Target, DtlOpts);
+                    do_compile(Config, Source, Target, DtlOpts);
                 false ->
                     skipped
             end
     end.
 
-do_compile(Source, Target, DtlOpts) ->
+do_compile(Config, Source, Target, DtlOpts) ->
     %% TODO: Check last mod on target and referenced DTLs here..
 
     %% ensure that doc_root and out_dir are defined,
@@ -208,19 +208,17 @@ do_compile(Source, Target, DtlOpts) ->
     case erlydtl:compile(Source,
                          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
+        ok ->
+            ok;
+        error ->
+            rebar_base_compiler:error_tuple(Config, Source, [], [], Opts);
+        {error, {_File, _Msgs} = Error} ->
+            rebar_base_compiler:error_tuple(Config, Source, [Error], [], Opts);
+        {error, Msg} ->
+            Es = [{Source, [{erlydtl_parser, Msg}]}],
+            rebar_base_compiler:error_tuple(Config, Source, Es, [], Opts)
     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")).


Mime
View raw message