lib/finix/response/finix_error_middleware.rb in finix-0.10 vs lib/finix/response/finix_error_middleware.rb in finix-0.11

- old
+ new

@@ -3,22 +3,13 @@ module Faraday class Response::RaiseApiError < Response::Middleware - HTTP_STATUS_CODES = { - 400 => Finix::BadRequest, - 401 => Finix::Unauthorized, - 403 => Finix::Forbidden, - 404 => Finix::NotFound, - 405 => Finix::MethodNotAllowed, - 422 => Finix::UnprocessableEntity - } - def on_complete(response) status_code = response[:status].to_i - error_class = HTTP_STATUS_CODES[status_code] - raise Finix::ResourceErrors.new(response) if error_class.nil? and status_code >= 400 + error_class = Finix.errors_registry[status_code] + raise Finix.errors_registry[:unknown].new(response) if error_class.nil? and status_code >= 400 raise error_class.new(response) if error_class end end