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

Keep error info #21

merged 2 commits into from
Jun 6, 2017

Conversation

lucafavatella
Copy link
Contributor

Depends on PR #20 (in order for build to pass on Travis CI.)

1. Report wrong datatype of the bucket if key not found rather then
   considering the error as plain "key not found" error.

  * This also improves readibility by:
    * Clarifying what the value discarded before error reporting is;
    * Hardcoding the expectation of the module of map data type.

  * See also:
    * https://github.com/basho/riak-erlang-client/blob/2.5.2/src/riakc_pb_socket.erl#L1262-L1264
    * https://github.com/basho/riak-erlang-client/blob/2.5.2/src/riakc_datatype.erl#L94

2. Tag errors while streaming keys as such, because caller may not
   expect key streaming error while having requested apparently
   completely separate operation.

3. Keep whether streaming error is timeout or other error;

4. Hardcode expectation of no continuation in key stream, because no
   max number of results specificied when requesting key stream in the
   first place.

  * Refs:
    * https://github.com/basho/riak-erlang-client/blob/2.5.2/src/riakc_pb_socket.erl#L1019-L1023
    * https://github.com/basho/riak-erlang-client/blob/2.5.2/src/riakc_pb_socket.erl#L1806-L1814
    * https://github.com/basho/riak-erlang-client/blob/2.5.2/include/riakc.hrl#L151-L156
    * https://github.com/basho/riak_test/blob/743d5dfb20717a81bb79392522c0581309205d76/tests/secondary_index_tests.erl#L204-L235

5. Prefer `exit` over `throw` in order to keep stacktrace.

  * See also inaka/erlang_guidelines#71

6. Keep most information on errors while persisting.

  * Function for persisting has room for improvements - out of scope
    for this commit though.

Also perform minor clarification of variable name in stream reception.

----

These changes are beneficial when attempting to determing why
something does not work. E.g. if a user attempt to get started on
sumo_db_riak with a Riak configured with bitcask backend rather than
leveldb then these changes make the error be like the following (this
is an excerpt from a test suite run - note strings `stream_keys`,
`indexes_not_supported,riak_kv_bitcask_backend`):

```
%%% basic_SUITE ==> find: SKIPPED
%%% basic_SUITE ==> {tc_auto_skip,
    {auto_skipped,
        {failed,
            {basic_SUITE,init_per_testcase,
                {{error,
                     {stream_keys,
                         {unexpected,
                             {82448287,
                              {error,
                                  <<"{error,{indexes_not_supported,riak_kv_bitcask_backend}}">>}}},
                         0}},
                 [{sumo,delete_all,1,
                      [{file,
                           "/Users/luca/dev/vuk/inaka_crud/sumo_db_riak/_build/default/lib/sumo_db/src/sumo.erl"},
                       {line,227}]},
                  {sumo_basic_test_helper,init_store,1,
                      [{file,
                           "/Users/luca/dev/vuk/inaka_crud/sumo_db_riak/_build/default/lib/sumo_db/src/adapter_test_helpers/sumo_basic_test_helper.erl"},
                       {line,165}]},
                  {basic_SUITE,init_per_testcase,2,
                      [{file,
                           "/Users/luca/dev/vuk/inaka_crud/sumo_db_riak/_build/test/lib/sumo_db_riak/test/basic_SUITE.erl"},
                       {line,51}]},
                  {test_server,do_init_per_testcase,2,
                      [{file,"test_server.erl"},{line,1297}]},
                  {test_server,run_test_case_eval1,6,
                      [{file,"test_server.erl"},{line,1007}]},
                  {test_server,run_test_case_eval,9,
                      [{file,"test_server.erl"},{line,977}]}]}}}}}
```
@@ -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()])

@elbrujohalcon
Copy link
Member

dialyzer warning will be fixed in #30

@elbrujohalcon elbrujohalcon merged commit 1bb226f into inaka:master Jun 6, 2017
@lucafavatella lucafavatella deleted the keep-error-info branch June 13, 2017 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants