riak-ripple / ripple

A rich Ruby modeling layer for Riak, Basho's distributed database
Other
619 stars 152 forks source link

ProtobuffsFailedRequest takes a code but its not available from the object #234

Closed eliaslevy closed 12 years ago

eliaslevy commented 12 years ago

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.

seancribbs commented 12 years ago

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 class), via super.

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

eliaslevy commented 12 years ago

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.

On Sat, Oct 29, 2011 at 9:02 PM, Sean Cribbs < reply@reply.github.com>wrote:

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 class), via super.

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

Reply to this email directly or view it on GitHub: https://github.com/seancribbs/ripple/issues/234#issuecomment-2568225

eliaslevy commented 12 years ago

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

seancribbs commented 12 years ago

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

seancribbs commented 12 years ago

Moved to https://github.com/basho/riak-ruby-client/issues/7