diff options
| author | Fred Hebert <mononcqc@ferd.ca> | 2015-06-16 21:08:46 -0400 | 
|---|---|---|
| committer | Fred Hebert <mononcqc@ferd.ca> | 2015-06-16 21:08:46 -0400 | 
| commit | 16be57b66c5de3af0ba498f46885d3aa812b215c (patch) | |
| tree | 18f4b643209616f91eb9be7b65375f019564b182 /src | |
| parent | ef4c2184563121ae23b003a0d07bd0922e85ce1b (diff) | |
| parent | 2d301ffca2e668badaa31532e046218ec289968e (diff) | |
Merge pull request #520 from tsloughter/undef_do
print nice error message if do is undef for provider
Diffstat (limited to 'src')
| -rw-r--r-- | src/rebar_core.erl | 15 | 
1 files changed, 13 insertions, 2 deletions
| diff --git a/src/rebar_core.erl b/src/rebar_core.erl index c7cc45a..7439cff 100644 --- a/src/rebar_core.erl +++ b/src/rebar_core.erl @@ -26,9 +26,10 @@  %% -------------------------------------------------------------------  -module(rebar_core). --export([init_command/2, process_namespace/2, process_command/2, do/2]). +-export([init_command/2, process_namespace/2, process_command/2, do/2, format_error/1]).  -include("rebar.hrl"). +-include_lib("providers/include/providers.hrl").  init_command(State, do) ->      process_command(rebar_state:namespace(State, default), do); @@ -120,9 +121,19 @@ do([ProviderName | Rest], State) ->                                    ,rebar_state:namespace(State))      end, -    case providers:do(Provider, State) of +    try providers:do(Provider, State) of          {ok, State1} ->              do(Rest, State1);          {error, Error} ->              {error, Error} +    catch +        error:undef -> +            %% This should really only happen if a plugin provider doesn't export do/1 +            ?DEBUG("Undefined call to provider's do function:~n~p", [erlang:get_stacktrace()]), +            ?PRV_ERROR({bad_provider_namespace, ProviderName})      end. + +format_error({bad_provider_namespace, {Namespace, Name}}) -> +    io_lib:format("Undefined command ~s in namespace ~s", [Name, Namespace]); +format_error({bad_provider_namespace, Name}) -> +    io_lib:format("Undefined command ~s", [Name]). | 
