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.
Adds an
error(status, message)
method available torequest
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 toUnknownError
, and a newHTTPError
class was defined -- one that can takemessage
andhttp_status_code
as arguments in it's initializer. This, in turn, allowed me to simplify theHTTPError
hierarchy by switching toattr_reader
for defining thehttp_status_code
andmessage
methods, and use ivars in all the descendants ofHTTPError
, DRYing up the error classes a lot.