diff options
author | Eric <[email protected]> | 2012-09-14 09:24:30 -0500 |
---|---|---|
committer | Eric <[email protected]> | 2012-09-18 10:04:05 -0700 |
commit | 9ed1132fb5a6150a051431fb14b42b800bdd323a (patch) | |
tree | fd722cb5213c651ab2c61e517834eef3a5e8b1ef | |
parent | 9efadeb73a53d254dd64a0fa1d50b3363d5f993c (diff) | |
download | relx-9ed1132fb5a6150a051431fb14b42b800bdd323a.tar.gz relx-9ed1132fb5a6150a051431fb14b42b800bdd323a.tar.bz2 relx-9ed1132fb5a6150a051431fb14b42b800bdd323a.zip |
cleanup and clarify provider spec
-rw-r--r-- | src/rcl_provider.erl | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/rcl_provider.erl b/src/rcl_provider.erl index 5c73075..5aa10bd 100644 --- a/src/rcl_provider.erl +++ b/src/rcl_provider.erl @@ -8,7 +8,7 @@ -module(rcl_provider). %% API --export([new/2, do/2, format/1]). +-export([new/2, do/2, format_error/2, format/1]). -export_type([t/0]). @@ -20,7 +20,7 @@ -callback init(rcl_state:t()) -> {ok, rcl_state:t()} | {error, Reason::term()}. -callback do(rcl_state:t()) -> {error, Reason::term()} | {ok, rcl_state:t()}. --callback format({error, Reason::term()}) -> iolist(). +-callback format_error({error, Reason::term()}) -> iolist(). %%%=================================================================== %%% API @@ -31,7 +31,8 @@ %% %% @param ModuleName The module name. %% @param State0 The current state of the system --spec new(module(), rcl_state:t()) -> {t(), {ok, rcl_state:t()} | {error, Reason::term()}}. +-spec new(module(), rcl_state:t()) -> + {t(), {ok, rcl_state:t()} | {error, Reason::term()}}. new(ModuleName, State0) when is_atom(ModuleName) -> State1 = ModuleName:init(State0), case code:which(ModuleName) of @@ -46,10 +47,17 @@ new(ModuleName, State0) when is_atom(ModuleName) -> %% %% @param Provider the provider object %% @param State the current state of the system --spec do(Provider::t(), rcl_state:t()) -> rcl_state:t(). +-spec do(Provider::t(), rcl_state:t()) -> + {error, Reason::term()} | {ok, rcl_state:t()}. do({?MODULE, Mod}, State) -> Mod:do(State). +%% @doc format an error produced from a provider. +-spec format_error(t(), {error, Reason::term()}) -> iolist(). +format_error({?MODULE, Mod}, Error) -> + Mod:format_error(Error). + + %% @doc print the provider module name %% %% @param T - The provider |