Class: Verizon::EdgeDiscoveryResultException

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

Overview

Base type for all errors.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(reason, response) ⇒ EdgeDiscoveryResultException

The constructor.

Parameters:

  • reason (String)

    The reason for raising an exception.

  • response (HttpResponse)

    The HttpReponse of the API call.



28
29
30
31
32
# File 'lib/verizon/exceptions/edge_discovery_result_exception.rb', line 28

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

Instance Attribute Details

#dataEdgeDiscoveryResultData

For cases where user input exceeds the boundary values an additional ‘data’ key will be returned with a relevant description.



23
24
25
# File 'lib/verizon/exceptions/edge_discovery_result_exception.rb', line 23

def data
  @data
end

#messageString

Error details.

Returns:

  • (String)


18
19
20
# File 'lib/verizon/exceptions/edge_discovery_result_exception.rb', line 18

def message
  @message
end

#statusString

HTTP status code or status of response.

Returns:

  • (String)


14
15
16
# File 'lib/verizon/exceptions/edge_discovery_result_exception.rb', line 14

def status
  @status
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



52
53
54
55
56
# File 'lib/verizon/exceptions/edge_discovery_result_exception.rb', line 52

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

#to_sObject

Provides a human-readable string representation of the object.



46
47
48
49
# File 'lib/verizon/exceptions/edge_discovery_result_exception.rb', line 46

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} status: #{@status}, message: #{@message}, data: #{@data}>"
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



37
38
39
40
41
42
43
# File 'lib/verizon/exceptions/edge_discovery_result_exception.rb', line 37

def unbox(hash)
  return nil unless hash

  @status = hash.key?('status') ? hash['status'] : nil
  @message = hash.key?('message') ? hash['message'] : nil
  @data = EdgeDiscoveryResultData.from_hash(hash['data']) if hash['data']
end