styleseek/hyperdrive — pull request #23 by xentek (2014-05-06 19:46:38+00:00)
Title: 9 error dsl

Adds an `error(status, message)` method available to `request` blocks defined with the DSL. This will raise an exception with the info you provide, which in turn will be rescued and formatted for return to your API users.

To accomplish this, the current implementation of `HTTPError` was renamed to `UnknownError`, and a new `HTTPError` class was defined -- one that can take `message` and `http_status_code` as arguments in it's initializer. This, in turn, allowed me to simplify the `HTTPError` hierarchy by switching to `attr_reader` for defining the `http_status_code` and `message` methods, and use ivars in all the descendants of `HTTPError`, DRYing up the error classes a lot.