Exception: Raas::RaasClientException
- Inherits:
-
APIException
- Object
- StandardError
- APIException
- Raas::RaasClientException
- Defined in:
- lib/raas/exceptions/raas_client_exception.rb
Instance Attribute Summary collapse
-
#errors ⇒ List of RaasClientErrorModel
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) ⇒ RaasClientException
constructor
The constructor.
-
#unbox(hash) ⇒ Object
Populates this object by extracting properties from a hash.
Constructor Details
#initialize(reason, context) ⇒ RaasClientException
The constructor.
33 34 35 36 37 38 39 40 |
# File 'lib/raas/exceptions/raas_client_exception.rb', line 33 def initialize(reason, context) super(reason, context) begin hash = APIHelper.json_deserialize(@context.response.raw_body) unbox(hash) rescue TypeError end end |
Instance Attribute Details
#errors ⇒ List of RaasClientErrorModel
An array of errors
28 29 30 |
# File 'lib/raas/exceptions/raas_client_exception.rb', line 28 def errors @errors end |
#http_code ⇒ Integer
HTTP Code
20 21 22 |
# File 'lib/raas/exceptions/raas_client_exception.rb', line 20 def http_code @http_code end |
#http_phrase ⇒ String
HTTP Phrase
24 25 26 |
# File 'lib/raas/exceptions/raas_client_exception.rb', line 24 def http_phrase @http_phrase end |
#path ⇒ String
Request Path
16 17 18 |
# File 'lib/raas/exceptions/raas_client_exception.rb', line 16 def path @path end |
#request_id ⇒ String
Request ID
12 13 14 |
# File 'lib/raas/exceptions/raas_client_exception.rb', line 12 def request_id @request_id end |
#timestamp ⇒ DateTime
Request timestamp
8 9 10 |
# File 'lib/raas/exceptions/raas_client_exception.rb', line 8 def @timestamp end |
Instance Method Details
#unbox(hash) ⇒ Object
Populates this object by extracting properties from a hash.
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/raas/exceptions/raas_client_exception.rb', line 44 def unbox(hash) @timestamp = DateTime.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 if hash['errors'] != nil @errors = Array.new hash['errors'].each{|structure| @errors << (RaasClientErrorModel.from_hash(structure) if structure)} end end |