Exception: Raas::RaasGenericException

Inherits:
APIException
  • Object
show all
Defined in:
lib/raas/exceptions/raas_generic_exception.rb

Overview

RaaS API Generic Exception

Instance Attribute Summary collapse

Attributes inherited from APIException

#context, #response_code

Instance Method Summary collapse

Constructor Details

#initialize(reason, context) ⇒ RaasGenericException

The constructor.

Parameters:

  • The (String)

    reason for raising an exception.

  • The (HttpContext)

    HttpContext of the API call.



35
36
37
38
39
# File 'lib/raas/exceptions/raas_generic_exception.rb', line 35

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

Instance Attribute Details

#http_codeInteger

HTTP Code

Returns:

  • (Integer)


22
23
24
# File 'lib/raas/exceptions/raas_generic_exception.rb', line 22

def http_code
  @http_code
end

#http_phraseString

HTTP Phrase

Returns:



26
27
28
# File 'lib/raas/exceptions/raas_generic_exception.rb', line 26

def http_phrase
  @http_phrase
end

#messageString

Error Message

Returns:



30
31
32
# File 'lib/raas/exceptions/raas_generic_exception.rb', line 30

def message
  @message
end

#pathString

Request Path

Returns:



18
19
20
# File 'lib/raas/exceptions/raas_generic_exception.rb', line 18

def path
  @path
end

#request_idString

Request ID

Returns:



14
15
16
# File 'lib/raas/exceptions/raas_generic_exception.rb', line 14

def request_id
  @request_id
end

#timestampDateTime

Request timestamp

Returns:

  • (DateTime)


10
11
12
# File 'lib/raas/exceptions/raas_generic_exception.rb', line 10

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



44
45
46
47
48
49
50
51
# File 'lib/raas/exceptions/raas_generic_exception.rb', line 44

def unbox(hash)
  @timestamp = APIHelper.rfc3339(hash['timestamp']) if hash['timestamp']
  @request_id = hash['requestId']
  @path = hash['path']
  @http_code = hash['httpCode']
  @http_phrase = hash['httpPhrase']
  @message = hash['message']
end