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.



20
21
22
23
24
# File 'lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/error_with_request_exception.rb', line 20

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)


11
12
13
# File 'lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/error_with_request_exception.rb', line 11

def error
  @error
end

#request_idString

The associated requestId from AWS

Returns:

  • (String)


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

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



29
30
31
32
# File 'lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/error_with_request_exception.rb', line 29

def unbox(hash)
  @error = hash['error']
  @request_id = hash['requestId']
end