diff options
author | Fred Hebert <mononcqc@ferd.ca> | 2015-06-19 16:43:19 -0400 |
---|---|---|
committer | Fred Hebert <mononcqc@ferd.ca> | 2015-06-19 16:43:19 -0400 |
commit | 8bd24214cbcc7d68514bee43d736837e2de84808 (patch) | |
tree | fc440acd698758cb0f1b05347bb4a2d79b097af5 /src | |
parent | 70dbbf95c24c054514e0ef2ba28c765d33bbf5d7 (diff) | |
parent | 4bb2a0c71006784442f285bbfac7559e4be51f67 (diff) |
Merge pull request #522 from tsloughter/hooks_error
Add error message for bad provider hook, fixes #521
Diffstat (limited to 'src')
-rw-r--r-- | src/rebar_core.erl | 4 | ||||
-rw-r--r-- | src/rebar_hooks.erl | 29 |
2 files changed, 22 insertions, 11 deletions
diff --git a/src/rebar_core.erl b/src/rebar_core.erl index 7439cff..b1647f0 100644 --- a/src/rebar_core.erl +++ b/src/rebar_core.erl @@ -130,7 +130,9 @@ do([ProviderName | Rest], State) -> 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}) + ?PRV_ERROR({bad_provider_namespace, ProviderName}); + error:{badrecord,provider} -> + {error, ProviderName} end. format_error({bad_provider_namespace, {Namespace, Name}}) -> diff --git a/src/rebar_hooks.erl b/src/rebar_hooks.erl index 9518542..ebc4d2d 100644 --- a/src/rebar_hooks.erl +++ b/src/rebar_hooks.erl @@ -1,6 +1,9 @@ -module(rebar_hooks). --export([run_all_hooks/5]). +-export([run_all_hooks/5 + ,format_error/1]). + +-include_lib("providers/include/providers.hrl"). -spec run_all_hooks(file:filename_all(), pre | post, atom() | {atom(), atom()} | string(), @@ -18,13 +21,21 @@ run_provider_hooks(Dir, Type, Command, Providers, State) -> TypeHooks = proplists:get_value(Type, AllHooks, []), HookProviders = proplists:get_all_values(Command, TypeHooks), - State2 = rebar_core:do(HookProviders, State1), - rebar_utils:remove_from_code_path(PluginDepsPaths), - State2. + case rebar_core:do(HookProviders, State1) of + {error, ProviderName} -> + throw(?PRV_ERROR({bad_provider, Type, Command, ProviderName})); + {ok, _} -> + rebar_utils:remove_from_code_path(PluginDepsPaths) + end. + +format_error({bad_provider, Type, Command, {Name, Namespace}}) -> + io_lib:format("Unable to run ~s hooks for '~p', command '~p' in namespace '~p' not found.", [Type, Command, Namespace, Name]); +format_error({bad_provider, Type, Command, Name}) -> + io_lib:format("Unable to run ~s hooks for '~p', command '~p' not found.", [Type, Command, Name]). %% @doc The following environment variables are exported when running %% a hook (absolute paths): -%% +%% %% REBAR_DEPS_DIR = rebar_dir:deps_dir/1 %% REBAR_BUILD_DIR = rebar_dir:base_dir/1 %% REBAR_ROOT_DIR = rebar_dir:root_dir/1 @@ -36,7 +47,7 @@ run_provider_hooks(Dir, Type, Command, Providers, State) -> %% REBAR_APP_DIRS = rebar_dir:lib_dirs/1 %% REBAR_SRC_DIRS = rebar_dir:src_dirs/1 %% -%% autoconf compatible variables +%% autoconf compatible variables %% (see: http://www.gnu.org/software/autoconf/manual/autoconf.html#Erlang-Libraries): %% ERLANG_ERTS_VER = erlang:system_info(version) %% ERLANG_ROOT_DIR = code:root_dir/0 @@ -100,8 +111,6 @@ join_dirs(BaseDir, Dirs) -> re_version(Path) -> case re:run(Path, "^.*-(?<VER>[^/-]*)$", [{capture, [1], list}]) of - nomatch -> ""; - {match, [Ver]} -> Ver + nomatch -> ""; + {match, [Ver]} -> Ver end. - - |