Exception: Raas::RaasServerException
- Inherits:
-
APIException
- Object
- StandardError
- APIException
- Raas::RaasServerException
- Defined in:
- lib/raas/exceptions/raas_server_exception.rb
Overview
RaaS API 5xx Exception
Instance Attribute Summary collapse
-
#errors ⇒ List of RaasServerErrorModel
An array of errors.
-
#http_code ⇒ Integer
HTTP Code.
-
#http_phrase ⇒ String
HTTP Phrase.
-
#path ⇒ String
Request Path.
-
#request_id ⇒ String
Request ID.
-
#timestamp ⇒ DateTime
Request timestamp.
Attributes inherited from APIException
Instance Method Summary collapse
-
#initialize(reason, context) ⇒ RaasServerException
constructor
The constructor.
-
#unbox(hash) ⇒ Object
Populates this object by extracting properties from a hash.
Constructor Details
#initialize(reason, context) ⇒ RaasServerException
The constructor.
35 36 37 38 39 |
# File 'lib/raas/exceptions/raas_server_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
#errors ⇒ List of RaasServerErrorModel
An array of errors
30 31 32 |
# File 'lib/raas/exceptions/raas_server_exception.rb', line 30 def errors @errors end |
#http_code ⇒ Integer
HTTP Code
22 23 24 |
# File 'lib/raas/exceptions/raas_server_exception.rb', line 22 def http_code @http_code end |
#http_phrase ⇒ String
HTTP Phrase
26 27 28 |
# File 'lib/raas/exceptions/raas_server_exception.rb', line 26 def http_phrase @http_phrase end |
#path ⇒ String
Request Path
18 19 20 |
# File 'lib/raas/exceptions/raas_server_exception.rb', line 18 def path @path end |
#request_id ⇒ String
Request ID
14 15 16 |
# File 'lib/raas/exceptions/raas_server_exception.rb', line 14 def request_id @request_id end |
#timestamp ⇒ DateTime
Request timestamp
10 11 12 |
# File 'lib/raas/exceptions/raas_server_exception.rb', line 10 def @timestamp end |
Instance Method Details
#unbox(hash) ⇒ Object
Populates this object by extracting properties from a hash. response body.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/raas/exceptions/raas_server_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 << (RaasServerErrorModel.from_hash(structure) if structure) end end end |