Skip to content

Commit

Permalink
Merge pull request #21 from lucafavatella/keep-error-info
Browse files Browse the repository at this point in the history
Keep error info
  • Loading branch information
Brujo Benavides authored Jun 6, 2017
2 parents 67ccbc7 + e81bfd6 commit 1bb226f
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/sumo_store_riak.erl
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ fetch(DocName, Id, State) ->
case fetch_map(Conn, Bucket, sumo_utils:to_bin(Id), Opts) of
{ok, RMap} ->
{ok, rmap_to_doc(DocName, RMap), State};
{error, {notfound, _}} ->
{error, {notfound, _Type = map}} ->
{error, notfound, State};
{error, Error} ->
{error, Error, State}
Expand Down Expand Up @@ -202,8 +202,8 @@ delete_all(_DocName, State) ->
Acc + length(Kst)
end,
case stream_keys(Conn, Bucket, Del, 0) of
{ok, Count} -> {ok, Count, State};
{_, Count} -> {error, Count, State}
{ok, Count} -> {ok, Count, State};
{error, Reason, Count} -> {error, {stream_keys, Reason, Count}, State}
end.

-spec find_all(DocName, State) -> Response when
Expand All @@ -216,8 +216,8 @@ find_all(DocName, State) ->
fetch_docs(DocName, Conn, Bucket, Kst, Opts) ++ Acc
end,
case stream_keys(Conn, Bucket, Get, []) of
{ok, Docs} -> {ok, Docs, State};
{_, Docs} -> {error, Docs, State}
{ok, Docs} -> {ok, Docs, State};
{error, Reason, Count} -> {error, {stream_keys, Reason, Count}, State}
end.

-spec find_all(DocName, Sort, Limit, Offset, State) -> Response when
Expand Down Expand Up @@ -489,8 +489,8 @@ new_doc(Doc, #state{conn = Conn, bucket = Bucket, put_opts = Opts}) ->
undefined ->
case update_map(Conn, Bucket, undefined, doc_to_rmap(Doc), Opts) of
{ok, RiakMapId} -> RiakMapId;
{error, Error} -> throw(Error);
_ -> throw(unexpected)
{error, Error} -> exit(Error);
Unexpected -> exit({unexpected, Unexpected})
end;
Id0 ->
sumo_utils:to_bin(Id0)
Expand Down Expand Up @@ -549,14 +549,14 @@ stream_keys(Conn, Bucket, F, Acc) ->
%% @private
receive_stream(Ref, F, Acc) ->
receive
{Ref, {_, Stream, _}} ->
receive_stream(Ref, F, F(Stream, Acc));
{Ref, {done, _}} ->
{Ref, {_, Keys, _}} ->
receive_stream(Ref, F, F(Keys, Acc));
{Ref, {done, _Continuation = undefined}} ->
{ok, Acc};
_ ->
{error, Acc}
Unexpected ->
{error, {unexpected, Unexpected}, Acc}
after
30000 -> {timeout, Acc}
30000 -> {error, timeout, Acc}
end.

%% @private
Expand Down

0 comments on commit 1bb226f

Please sign in to comment.