aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEric <[email protected]>2012-10-26 13:54:59 -0500
committerJordan Wilberding <[email protected]>2012-10-30 09:54:42 -0600
commitb8d54a7736f3b75d442de1f0239a7b5b3c0f8528 (patch)
tree4067a78b261830cdba5ed49fb4d65df9406a3fa9 /src
parentdb8412d1f71a3498c6214fa255f28e3ee1e54a56 (diff)
downloadrelx-b8d54a7736f3b75d442de1f0239a7b5b3c0f8528.tar.gz
relx-b8d54a7736f3b75d442de1f0239a7b5b3c0f8528.tar.bz2
relx-b8d54a7736f3b75d442de1f0239a7b5b3c0f8528.zip
make sure that the system does not exit when the API is used
Signed-off-by: Jordan Wilberding <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/relcool.erl11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/relcool.erl b/src/relcool.erl
index 13ef2ea..44debc9 100644
--- a/src/relcool.erl
+++ b/src/relcool.erl
@@ -83,7 +83,10 @@ opt_spec_list() ->
-spec format_error(Reason::term()) -> iolist().
format_error({invalid_return_value, Provider, Value}) ->
[rcl_provider:format(Provider), " returned an invalid value ",
- io_lib:format("~p", [Value])].
+ io_lib:format("~p", [Value])];
+format_error({error, {Module, Reason}}) ->
+ io_lib:format("~s~n", [Module:format_error(Reason)]).
+
%%============================================================================
%% internal api
@@ -136,7 +139,7 @@ run_provider(Provider, {ok, State0}) ->
{ok, State1} ->
{ok, State1};
E={error, _} ->
- report_error(State0, E)
+ E
end.
-spec usage() -> ok.
@@ -145,8 +148,8 @@ usage() ->
-spec report_error(rcl_state:t(), error()) -> none() | error().
-report_error(State, Error={error, {Module, Reason}}) ->
- io:format("~s~n", [Module:format_error(Reason)]),
+report_error(State, Error) ->
+ io:format(format_error(Error)),
usage(),
case rcl_state:caller(State) of
command_line ->