basho/riak-ruby-client — Issue #7: ProtobuffsFailedRequest takes a code but its not available from the object
Author: seancribbs
Created: 2012-01-12 21:14:43+00:00
State: open
Labels: refactor

Moved from https://github.com/seancribbs/ripple/issues/234 by @eliaslevy:

ProtobuffsFailedRequest takes an error code as an argument, but the code is not available from the object, as its not used by the FailedRequest base class.

Similarly the message is passed as the :body argument to the parent, but the parent those not use it or store it.

Presumably the code for managing the error code and original message where going to be moved from the HTTPFailedRequest class to its parent the FailedRequest class, so that these would be available to both HTTPFailedRequest and ProtobuffsFailedRequest.

## Copied Comments

#### @seancribbs on October 30, 2011

The `code` is not available because there are only two options, `:not_found` and `:server_error`, which are both exposed as "query" methods (and are semantically more useful in my opinion). The message becomes part of the exception's message (accessible as defined on the [Exception](http://ruby-doc.org/core-1.9.2/Exception.html) class), via `super`.

The two Riak interfaces are not 100% feature-equivalent, and therefore they are not treated equally.

#### @seancribbs closed the issue on October 30, 2011

#### @eliaslevy on October 30, 2011

There is at least one more possible code: :stale_object.
From beefcake_protobuffs_backend.rb:store_object,

raise Riak::ProtobuffsFailedRequest(:stale_object, t(
"stale_write_prevented")) unless other.vclock == robject.vclock

You may want to add stale_object as another query method. As it is, at the
moment I have to dig into the exception instance variable to get the
original message to compare it to "stale_write_prevented", and that may not
work if the string is replaced by something else by the
internationalization code.

#### @eliaslevy on October 30, 2011

Sean, given my comment above, do you consider this issue closed?

#### @seancribbs reopened the issue on October 30, 2011

#### @seancribbs on October 30, 2011

Reopened. Next time you should just say what you're trying to accomplish, it'll help me better understand what the problem is.