aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric <[email protected]>2012-12-06 18:12:53 -0500
committerJordan Wilberding <[email protected]>2012-12-07 05:49:59 -0700
commit819690cd8bda0f7f91740b8fa5df71256656de52 (patch)
treeb5e1d71e7935e0f1f3a9118638e05c574f8a63aa
parentd88598d9748c89a7f3d041e078bc8e2b544b5da9 (diff)
downloadrelx-819690cd8bda0f7f91740b8fa5df71256656de52.tar.gz
relx-819690cd8bda0f7f91740b8fa5df71256656de52.tar.bz2
relx-819690cd8bda0f7f91740b8fa5df71256656de52.zip
fix nasty bug that didn't let relcool output errors
Signed-off-by: Jordan Wilberding <[email protected]>
-rw-r--r--src/rcl_provider.erl7
-rw-r--r--src/relcool.erl18
2 files changed, 19 insertions, 6 deletions
diff --git a/src/rcl_provider.erl b/src/rcl_provider.erl
index 9d1dd88..c3ef434 100644
--- a/src/rcl_provider.erl
+++ b/src/rcl_provider.erl
@@ -10,6 +10,7 @@
%% API
-export([new/2,
do/2,
+ impl/1,
format_error/1,
format_error/2,
format/1]).
@@ -57,6 +58,12 @@ new(ModuleName, State0) when is_atom(ModuleName) ->
do({?MODULE, Mod}, State) ->
Mod:do(State).
+%%% @doc get the name of the module that implements the provider
+%%% @param Provider the provider object
+-spec impl(Provider::t()) -> module().
+impl({?MODULE, Mod}) ->
+ Mod.
+
%% @doc format an error produced from a provider.
-spec format_error(Reason::term()) -> iolist().
format_error({non_existing, ModuleName}) ->
diff --git a/src/relcool.erl b/src/relcool.erl
index 1c3ec02..0d75c62 100644
--- a/src/relcool.erl
+++ b/src/relcool.erl
@@ -128,14 +128,17 @@ run_providers(State0) ->
{ok, State1} ->
Providers = rcl_state:providers(State1),
Result = run_providers(ConfigProvider, Providers, State1),
- case rcl_state:caller(State1) of
- command_line ->
- init:stop(0);
- api ->
- Result
- end
+ handle_output(State1, rcl_state:caller(State1), Result)
end.
+handle_output(State, command_line, E={error, _}) ->
+ report_error(State, E),
+ init:stop(127);
+handle_output(_State, command_line, _) ->
+ init:stop(0);
+handle_output(_State, api, Result) ->
+ Result.
+
run_providers(ConfigProvider, Providers, State0) ->
case Providers of
[ConfigProvider | Rest] ->
@@ -151,10 +154,13 @@ run_providers(ConfigProvider, Providers, State0) ->
run_provider(_Provider, Error = {error, _}) ->
Error;
run_provider(Provider, {ok, State0}) ->
+ rcl_log:debug(rcl_state:log(State0), "Running provider ~p~n",
+ [rcl_provider:impl(Provider)]),
case rcl_provider:do(Provider, State0) of
{ok, State1} ->
{ok, State1};
E={error, _} ->
+
E
end.