Exception: Tester::NestedModelException

Inherits:
APIException
  • Object
show all
Defined in:
lib/tester/exceptions/nested_model_exception.rb

Overview

NestedModelException class.

Instance Attribute Summary collapse

Attributes inherited from APIException

#context, #response_code

Instance Method Summary collapse

Constructor Details

#initialize(reason, context) ⇒ NestedModelException

The constructor.

Parameters:

  • The (String)

    reason for raising an exception.

  • The (HttpContext)

    HttpContext of the API call.



22
23
24
25
26
# File 'lib/tester/exceptions/nested_model_exception.rb', line 22

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

Instance Attribute Details

#modelValidate

TODO: Write general description for this method

Returns:



17
18
19
# File 'lib/tester/exceptions/nested_model_exception.rb', line 17

def model
  @model
end

#server_codeString

TODO: Write general description for this method

Returns:



13
14
15
# File 'lib/tester/exceptions/nested_model_exception.rb', line 13

def server_code
  @server_code
end

#server_messageString

TODO: Write general description for this method

Returns:



9
10
11
# File 'lib/tester/exceptions/nested_model_exception.rb', line 9

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



31
32
33
34
35
# File 'lib/tester/exceptions/nested_model_exception.rb', line 31

def unbox(hash)
  @server_message = hash['ServerMessage']
  @server_code = hash['ServerCode']
  @model = Validate.from_hash(hash['model']) if hash['model']
end