Exception: Raas::RaasClientException

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

Overview

RaaS API 4xx Exception

Instance Attribute Summary collapse

Attributes inherited from APIException

#context, #response_code

Instance Method Summary collapse

Constructor Details

#initialize(reason, context) ⇒ RaasClientException

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_client_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

#errorsList of RaasClientErrorModel

An array of errors

Returns:



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

def errors
  @errors
end

#http_codeInteger

HTTP Code

Returns:

  • (Integer)


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

def http_code
  @http_code
end

#http_phraseString

HTTP Phrase

Returns:



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

def http_phrase
  @http_phrase
end

#pathString

Request Path

Returns:



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

def path
  @path
end

#request_idString

Request ID

Returns:



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

def request_id
  @request_id
end

#timestampDateTime

Request timestamp

Returns:

  • (DateTime)


10
11
12
# File 'lib/raas/exceptions/raas_client_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
52
53
54
55
56
57
58
# File 'lib/raas/exceptions/raas_client_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']
  # Parameter is an array, so we need to iterate through it

  @errors = nil
  unless hash['errors'].nil?
    @errors = []
    hash['errors'].each do |structure|
      @errors << (RaasClientErrorModel.from_hash(structure) if structure)
    end
  end
end