Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
zynamo: better checks for content of ring state file when starting up.
  • Loading branch information
mworrell committed Feb 1, 2013
1 parent 0299d1b commit b241126
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions deps/zynamo/src/zynamo_manager.erl
Expand Up @@ -387,10 +387,16 @@ do_save(Ring) ->
-spec do_read() -> {ok, ring()} | {error, term()}.
do_read() ->
case catch file:consult(ring_file()) of
{ok, Rings} ->
{ok, []} ->
error_logger:info_msg("Ring state file is empty."),
{error, empty};
{ok, Rings} when is_list(Rings) ->
{ok, hd(Rings)};
{error, _Reason} = Error ->
error_logger:info_msg("Error reading ring state:~n~n~p~n", [Error]),
{ok, _Content} ->
error_logger:info_msg("Ring state file doesn't contain a list."),
{error, illegal};
{error, Reason} = Error ->
error_logger:info_msg("Error reading ring state:~n~n~p~n", [Reason]),
Error
end.

Expand Down

0 comments on commit b241126

Please sign in to comment.