Exception: Bandwidth::ErrorWithRequestException

Inherits:
APIException
  • Object
show all
Defined in:
lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/error_with_request_exception.rb

Overview

ErrorWithRequest class.

Instance Attribute Summary collapse

Attributes inherited from APIException

#response, #response_code

Instance Method Summary collapse

Constructor Details

#initialize(reason, response) ⇒ ErrorWithRequestException

The constructor.

Parameters:

  • The (String)

    reason for raising an exception.

  • The (HttpResponse)

    HttpReponse of the API call.



23
24
25
26
27
# File 'lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/error_with_request_exception.rb', line 23

def initialize(reason, response)
  super(reason, response)
  hash = APIHelper.json_deserialize(@response.raw_body)
  unbox(hash)
end

Instance Attribute Details

#errorString

An error message pertaining to what the issue could be

Returns:

  • (String)


14
15
16
# File 'lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/error_with_request_exception.rb', line 14

def error
  @error
end

#request_idString

The associated requestId from AWS

Returns:

  • (String)


18
19
20
# File 'lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/error_with_request_exception.rb', line 18

def request_id
  @request_id
end

Instance Method Details

#unbox(hash) ⇒ Object

Populates this object by extracting properties from a hash. response body.

Parameters:

  • The (Hash)

    deserialized response sent by the server in the



32
33
34
35
# File 'lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/error_with_request_exception.rb', line 32

def unbox(hash)
  @error = hash.key?('error') ? hash['error'] : SKIP
  @request_id = hash.key?('requestId') ? hash['requestId'] : SKIP
end