iconara/cql-rb — pull request #119 by russCloak (2014-08-05 16:34:58+00:00)
Title: Raise specific errors with invalid UUID cases

It would be more helpful for developers integrating functionality at a
higher level if errors raised for invalid UUIDs are namespaced. This
adds a new Cql::Uuid::InvalidUuidError that improves two cases:

- The fix for jruby issue https://github.com/jruby/jruby/issues/1608
is no longer necessary because we are now raising an explicit error
describing that the UUID is invalid - so the reliance on raising an
ArgumentError in order to maintain consistency for Integer is no
longer necessary.

- The error messages are now more specific, and therefore more helpful
for when a developer is doing an integration. On the same note, the
errors being namespaced specifically under Cql::Uuid allows for a
rescue for specific cases, instead of the higher-level ArgumentError
that could occur in many other places, for many other reasons.

My specific use case is that I am creating an API that is on top of a cassandra datastore, so I am making use of the Cequel gem (uses this gem). I want to rescue specific errors that might happen so I can render 404, or 400 based on what happened. This error (ArgumentError) was occurring when someone would search for a record that uses a UUID as the key, but they wouldn't supply a proper UUID. Instead of rescuing ArgumentError, which is very high-level (and happened to swallow a lot more errors than it should have), it is much more useful to me if there is some kind of specific error to catch.