diff options
author | Tristan Sloughter <t@crashfast.com> | 2015-06-16 19:23:24 -0500 |
---|---|---|
committer | Tristan Sloughter <t@crashfast.com> | 2015-06-16 19:24:37 -0500 |
commit | 2d301ffca2e668badaa31532e046218ec289968e (patch) | |
tree | beaf0a857464e26f67ff48b27e6323b4d6373a82 | |
parent | 1972f1f85a25e15ccf13a6400dcb48183ae63624 (diff) |
print nice error message if do is undef for provider
-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]). |