Replace case catch ... with try catch

This commit is contained in:
Gilbert Wong 2019-02-26 10:41:15 +08:00
parent 65eba08912
commit 80cbf6cbb1
1 changed files with 5 additions and 2 deletions

View File

@ -112,10 +112,13 @@ handle_info({'EXIT', Pid, Reason}, State = #state{client = Pid, opts = Opts}) ->
end; end;
handle_info(reconnect, State = #state{opts = Opts}) -> handle_info(reconnect, State = #state{opts = Opts}) ->
case catch connect(State) of try connect(State) of
{ok, Client} -> {ok, Client} ->
{noreply, State#state{client = Client}}; {noreply, State#state{client = Client}};
{Err, _Reason} when Err =:= error orelse Err =:= 'EXIT' -> {error, _Reason} ->
reconnect(proplists:get_value(auto_reconnect, Opts), State)
catch
_Error:_Reason ->
reconnect(proplists:get_value(auto_reconnect, Opts), State) reconnect(proplists:get_value(auto_reconnect, Opts), State)
end; end;