From b8d54a7736f3b75d442de1f0239a7b5b3c0f8528 Mon Sep 17 00:00:00 2001 From: Eric Date: Fri, 26 Oct 2012 13:54:59 -0500 Subject: make sure that the system does not exit when the API is used Signed-off-by: Jordan Wilberding --- src/relcool.erl | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/relcool.erl') 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 -> -- cgit v1.2.3