Exception: Bandwidth::ApiErrorException

Inherits:
APIException
  • Object
show all
Defined in:
lib/bandwidth/voice_lib/voice/exceptions/api_error_exception.rb

Overview

ApiError class.

Instance Attribute Summary collapse

Attributes inherited from APIException

#response, #response_code

Instance Method Summary collapse

Constructor Details

#initialize(reason, response) ⇒ ApiErrorException

The constructor.

Parameters:

  • The (String)

    reason for raising an exception.

  • The (HttpResponse)

    HttpReponse of the API call.



27
28
29
30
31
# File 'lib/bandwidth/voice_lib/voice/exceptions/api_error_exception.rb', line 27

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

Instance Attribute Details

#descriptionString

TODO: Write general description for this method

Returns:

  • (String)


18
19
20
# File 'lib/bandwidth/voice_lib/voice/exceptions/api_error_exception.rb', line 18

def description
  @description
end

#idString

TODO: Write general description for this method

Returns:

  • (String)


22
23
24
# File 'lib/bandwidth/voice_lib/voice/exceptions/api_error_exception.rb', line 22

def id
  @id
end

#typeString

TODO: Write general description for this method

Returns:

  • (String)


14
15
16
# File 'lib/bandwidth/voice_lib/voice/exceptions/api_error_exception.rb', line 14

def type
  @type
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



36
37
38
39
40
# File 'lib/bandwidth/voice_lib/voice/exceptions/api_error_exception.rb', line 36

def unbox(hash)
  @type = hash.key?('type') ? hash['type'] : SKIP
  @description = hash.key?('description') ? hash['description'] : SKIP
  @id = hash.key?('id') ? hash['id'] : SKIP
end