浏览代码

catch error on multiplpe app files in an app dir

pull/6/head
Tristan Sloughter 10 年前
父节点
当前提交
8635beffc1
共有 2 个文件被更改,包括 20 次插入7 次删除
  1. +9
    -3
      src/rebar_app_discover.erl
  2. +11
    -4
      src/rebar_prv_app_discovery.erl

+ 9
- 3
src/rebar_app_discover.erl 查看文件

@ -70,7 +70,9 @@ find_app(AppDir, Validate) ->
[F] ->
rebar_app_info:app_file_src(AppInfo1, F);
[] ->
AppInfo1
AppInfo1;
Other when is_list(Other) ->
throw({error, {multiple_app_files, Other}})
end,
case Validate of
valid ->
@ -101,8 +103,12 @@ find_app(AppDir, Validate) ->
false
end;
[] ->
false
end
false;
Other when is_list(Other) ->
throw({error, {multiple_app_files, Other}})
end;
Other when is_list(Other) ->
throw({error, {multiple_app_files, Other}})
end.
app_dir(AppFile) ->

+ 11
- 4
src/rebar_prv_app_discovery.erl 查看文件

@ -33,9 +33,16 @@ init(State) ->
-spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}.
do(State) ->
LibDirs = rebar_state:get(State, lib_dirs, ?DEFAULT_LIB_DIRS),
State1 = rebar_app_discover:do(State, LibDirs),
{ok, State1}.
-spec format_error(any()) -> iolist().
try
State1 = rebar_app_discover:do(State, LibDirs),
{ok, State1}
catch
throw:{error, Error}->
{error, {?MODULE, Error}}
end.
-spec format_error(any()) -> iolist().
format_error({multiple_app_files, Files}) ->
io_lib:format("Multiple app files found in one app dir: ~s", [string:join(Files, " and ")]);
format_error(Reason) ->
io_lib:format("~p", [Reason]).

正在加载...
取消
保存