Class: Nylas::NylasApiError

Inherits:
AbstractNylasApiError show all
Defined in:
lib/nylas/errors.rb

Overview

Error class representing a failed response from the Nylas API.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, message, status_code, provider_error = nil, request_id = nil) ⇒ NylasApiError

Initializes an error and assigns the given attributes to it.

Parameters:

  • type (Hash)

    Error type.

  • message (String)

    Error message.

  • status_code (Integer)

    Error status code.

  • provider_error (Hash, nil) (defaults to: nil)

    The error from the provider.

  • request_id (Hash, nil) (defaults to: nil)

    The ID of the request.



26
27
28
29
30
31
32
# File 'lib/nylas/errors.rb', line 26

def initialize(type, message, status_code, provider_error = nil, request_id = nil)
  super(message)
  self.type = type
  self.status_code = status_code
  self.provider_error = provider_error
  self.request_id = request_id
end

Instance Attribute Details

#provider_errorObject

Returns the value of attribute provider_error.



17
18
19
# File 'lib/nylas/errors.rb', line 17

def provider_error
  @provider_error
end

#request_idObject

Returns the value of attribute request_id.



17
18
19
# File 'lib/nylas/errors.rb', line 17

def request_id
  @request_id
end

#status_codeObject

Returns the value of attribute status_code.



17
18
19
# File 'lib/nylas/errors.rb', line 17

def status_code
  @status_code
end

#typeObject

Returns the value of attribute type.



17
18
19
# File 'lib/nylas/errors.rb', line 17

def type
  @type
end

Class Method Details

.parse_error_response(response, status_code) ⇒ Object

Parses the error response.

Parameters:

  • response (Hash)

    Response from the Nylas API.

  • status_code (Integer)

    Error status code.



38
39
40
41
42
43
44
45
# File 'lib/nylas/errors.rb', line 38

def self.parse_error_response(response, status_code)
  new(
    response["type"],
    response["message"],
    status_code,
    response["provider_error"]
  )
end