Class: MailchimpAPI::FailedRequestErrorBuilder Private
- Inherits:
-
Object
- Object
- MailchimpAPI::FailedRequestErrorBuilder
- Defined in:
- lib/mailchimp-api/failed_request_error_builder.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Internal class for building failed request error instances
Constant Summary collapse
- RESPONSE_ERROR_MAP =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Maps HTTP response classes to corresponding Mailchimp API error classes
{ Net::HTTPBadRequest => Errors::BadRequest, # 400 Net::HTTPUnauthorized => Errors::Unauthorized, # 401 Net::HTTPForbidden => Errors::Forbidden, # 403 Net::HTTPNotFound => Errors::NotFound, # 404 Net::HTTPMethodNotAllowed => Errors::MethodNotAllowed, # 405 Net::HTTPRequestURITooLong => Errors::RequestURITooLong, # 414 Net::HTTPUnprocessableEntity => Errors::UnprocessableEntity, # 422 Net::HTTPUpgradeRequired => Errors::UpgradeRequired, # 426 Net::HTTPTooManyRequests => Errors::TooManyRequests, # 429 Net::HTTPServerError => Errors::ServerError # 5xx }.freeze
Class Method Summary collapse
-
.call(request:, response:) ⇒ Errors::FailedRequest
private
Creates a new error instance based on the HTTP response.
Class Method Details
.call(request:, response:) ⇒ Errors::FailedRequest
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Creates a new error instance based on the HTTP response
29 30 31 32 33 34 35 |
# File 'lib/mailchimp-api/failed_request_error_builder.rb', line 29 def call(request:, response:) http_response = response.http_response = "#{http_response.code} #{http_response.}" error_class = find_error_class(http_response) error_class.new(, response: response, request: request) end |