xentek / hyperdrive

hypermedia state machine
https://rubygems.org/gems/hyperdrive
MIT License
5 stars 0 forks source link

9 error dsl #23

Closed xentek closed 10 years ago

xentek commented 10 years ago

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.