Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep error info #21

Merged
merged 2 commits into from
Jun 6, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to Dialyzer:

The call sumo_store_riak:update_map(Conn::pid(), Bucket::{binary(),binary()}, 'undefined', {'map',[{{binary(),'counter' | 'flag' | 'map' | 'register' | 'set'},}],[{{binary(),'counter' | 'flag' | 'map' | 'register' | 'set'},}],[{binary(),'counter' | 'flag' | 'map' | 'register' | 'set'}],'undefined' | binary()}, Opts::['if_none_match' | 'if_not_modified' | 'return_body' | 'return_head' | {'dw','all' | 'default' | 'one' | 'quorum' | non_neg_integer()} | {'n_val',pos_integer()} | {'pw','all' | 'default' | 'one' | 'quorum' | non_neg_integer()} | {'sloppy_quorum',boolean()} | {'w','all' | 'default' | 'one' | 'quorum' | non_neg_integer()}]) will never return since it differs in the 3rd argument from the success typing arguments: (pid(), {binary(),binary()}, binary(), {'map',[{{,},}],[{{,},}],[{binary(),'counter' | 'flag' | 'map' | 'register' | 'set'}],'undefined' | binary()}, [atom() | tuple()])

{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