Exception: MailchimpAPI::Errors::NetworkError

Inherits:
MailchimpAPI::Error show all
Defined in:
lib/mailchimp-api/error.rb

Overview

Raised when a network error occurs while executing the request

Instance Attribute Summary

Attributes inherited from MailchimpAPI::Error

#error_detail, #error_fields, #error_instance, #error_status, #error_title, #error_type, #request, #response

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, request:, error:) ⇒ NetworkError

Initializes a new NetworkError

Examples:

begin
  client.get("/lists")
rescue MailchimpAPI::Errors::NetworkError => e
  puts e.error_title # => "Net::OpenTimeout"
  puts e.error_detail # => "execution expired"
end

Parameters:

  • message (String, nil) (defaults to: nil)

    Error message

  • request (Request)

    The request that failed

  • error (Exception)

    The original network error



77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/mailchimp-api/error.rb', line 77

def initialize(message = nil, request:, error:)
  super(message)
  @request = request
  @response = nil

  @error_type = nil
  @error_title = error.class.name
  @error_detail = error.message
  @error_status = nil
  @error_fields = nil
  @error_instance = nil
end