diff options
| author | Tristan Sloughter <t@crashfast.com> | 2014-11-16 10:22:46 -0600 | 
|---|---|---|
| committer | Tristan Sloughter <t@crashfast.com> | 2014-11-16 10:22:46 -0600 | 
| commit | 8635beffc1c9efc7e26f3cf1597b859a8a72bd3b (patch) | |
| tree | e7a0121b2246ec90abeb23357cf1764b4b63742c | |
| parent | 1d5703025cbfa3d9a6a943e5e1b7011611399380 (diff) | |
catch error on multiplpe app files in an app dir
| -rw-r--r-- | src/rebar_app_discover.erl | 12 | ||||
| -rw-r--r-- | src/rebar_prv_app_discovery.erl | 15 | 
2 files changed, 20 insertions, 7 deletions
| diff --git a/src/rebar_app_discover.erl b/src/rebar_app_discover.erl index ae4916e..4005612 100644 --- a/src/rebar_app_discover.erl +++ b/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) -> diff --git a/src/rebar_prv_app_discovery.erl b/src/rebar_prv_app_discovery.erl index ccc470b..b6cdf80 100644 --- a/src/rebar_prv_app_discovery.erl +++ b/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]). | 
