lib/ridley/errors.rb in ridley-0.8.1 vs lib/ridley/errors.rb in ridley-0.8.2

- old
+ new

@@ -37,10 +37,20 @@ class BootstrapError < RidleyError; end class ClientKeyFileNotFound < BootstrapError; end class EncryptedDataBagSecretNotFound < BootstrapError; end + # Exception thrown when the maximum amount of requests is exceeded. + class RedirectLimitReached < RidleyError + attr_reader :response + + def initialize(response) + super "too many redirects; last one to: #{response['location']}" + @response = response + end + end + class HTTPError < RidleyError class << self def fabricate(env) klass = lookup_error(env[:status].to_i) klass.new(env) @@ -85,20 +95,27 @@ super(env) @message = "status: #{env[:status]} is an unknown HTTP status code or not an error." end end + class HTTP3XXError < HTTPError; end class HTTP4XXError < HTTPError; end class HTTP5XXError < HTTPError; end + # 3XX + class HTTPMovedPermanently < HTTP3XXError; register_error(301); end + class HTTPFound < HTTP3XXError; register_error(302); end + + # 4XX class HTTPBadRequest < HTTP4XXError; register_error(400); end class HTTPUnauthorized < HTTP4XXError; register_error(401); end class HTTPForbidden < HTTP4XXError; register_error(403); end class HTTPNotFound < HTTP4XXError; register_error(404); end class HTTPMethodNotAllowed < HTTP4XXError; register_error(405); end class HTTPRequestTimeout < HTTP4XXError; register_error(408); end class HTTPConflict < HTTP4XXError; register_error(409); end - + + # 5XX class HTTPInternalServerError < HTTP5XXError; register_error(500); end class HTTPNotImplemented < HTTP5XXError; register_error(501); end class HTTPBadGateway < HTTP5XXError; register_error(502); end class HTTPServiceUnavailable < HTTP5XXError; register_error(503); end class HTTPGatewayTimeout < HTTP5XXError; register_error(504); end