Class: Verizon::DeviceDiagnosticsResultException

Inherits:
APIException
  • Object
show all
Defined in:
lib/verizon/exceptions/device_diagnostics_result_exception.rb

Overview

All error messages are returned in this format. Error codes and messages are listed on the Error Codes page, along with explanations and suggestions for corrective actions.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(reason, response) ⇒ DeviceDiagnosticsResultException

The constructor.

Parameters:

  • reason (String)

    The reason for raising an exception.

  • response (HttpResponse)

    The HttpReponse of the API call.



25
26
27
28
29
# File 'lib/verizon/exceptions/device_diagnostics_result_exception.rb', line 25

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

Instance Attribute Details

#error_codeString

Simple error code.

Returns:

  • (String)


16
17
18
# File 'lib/verizon/exceptions/device_diagnostics_result_exception.rb', line 16

def error_code
  @error_code
end

#error_messageString

Detailed error message.

Returns:

  • (String)


20
21
22
# File 'lib/verizon/exceptions/device_diagnostics_result_exception.rb', line 20

def error_message
  @error_message
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



48
49
50
51
52
# File 'lib/verizon/exceptions/device_diagnostics_result_exception.rb', line 48

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} error_code: #{@error_code.inspect}, error_message:"\
  " #{@error_message.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



42
43
44
45
# File 'lib/verizon/exceptions/device_diagnostics_result_exception.rb', line 42

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} error_code: #{@error_code}, error_message: #{@error_message}>"
end

#unbox(hash) ⇒ Object

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

Parameters:

  • hash (Hash)

    The deserialized response sent by the server in the



34
35
36
37
38
39
# File 'lib/verizon/exceptions/device_diagnostics_result_exception.rb', line 34

def unbox(hash)
  return nil unless hash

  @error_code = hash.key?('errorCode') ? hash['errorCode'] : nil
  @error_message = hash.key?('errorMessage') ? hash['errorMessage'] : nil
end