Exception: CtRegisterMicroservice::APIError
- Inherits:
-
CtRegisterMicroserviceError
- Object
- StandardError
- CtRegisterMicroserviceError
- CtRegisterMicroservice::APIError
- Defined in:
- lib/ct_register_microservice/errors.rb
Direct Known Subclasses
BadCTResponse, ClientError, NoTokenError, NotFoundError, OAuthTokenRequestError, ServerError
Instance Attribute Summary collapse
-
#ct_error_code ⇒ Object
Returns the value of attribute ct_error_code.
-
#ct_error_message ⇒ Object
Returns the value of attribute ct_error_message.
-
#ct_error_subcode ⇒ Object
Returns the value of attribute ct_error_subcode.
-
#ct_error_type ⇒ Object
Returns the value of attribute ct_error_type.
-
#ct_error_user_msg ⇒ Object
Returns the value of attribute ct_error_user_msg.
-
#ct_error_user_title ⇒ Object
Returns the value of attribute ct_error_user_title.
-
#http_status ⇒ Object
Returns the value of attribute http_status.
-
#response_body ⇒ Object
Returns the value of attribute response_body.
Instance Method Summary collapse
-
#initialize(http_status, response_body, error_message = nil) ⇒ APIError
constructor
A new instance of APIError.
Constructor Details
#initialize(http_status, response_body, error_message = nil) ⇒ APIError
Returns a new instance of APIError.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/ct_register_microservice/errors.rb', line 17 def initialize(http_status, response_body, = nil) if response_body self.response_body = response_body.strip else self.response_body = '' end self.http_status = http_status if && .is_a?(String) = else unless begin errors = MultiJson.load(response_body) if response_body error_array = errors['errors'].map { |n| n['detail'] } if errors.key? 'errors' rescue end error_array ||= [] end if error_array.nil? or error_array.empty? = self.response_body else = error_array.join(', ') end end super() end |
Instance Attribute Details
#ct_error_code ⇒ Object
Returns the value of attribute ct_error_code.
13 14 15 |
# File 'lib/ct_register_microservice/errors.rb', line 13 def ct_error_code @ct_error_code end |
#ct_error_message ⇒ Object
Returns the value of attribute ct_error_message.
13 14 15 |
# File 'lib/ct_register_microservice/errors.rb', line 13 def @ct_error_message end |
#ct_error_subcode ⇒ Object
Returns the value of attribute ct_error_subcode.
13 14 15 |
# File 'lib/ct_register_microservice/errors.rb', line 13 def ct_error_subcode @ct_error_subcode end |
#ct_error_type ⇒ Object
Returns the value of attribute ct_error_type.
13 14 15 |
# File 'lib/ct_register_microservice/errors.rb', line 13 def ct_error_type @ct_error_type end |
#ct_error_user_msg ⇒ Object
Returns the value of attribute ct_error_user_msg.
13 14 15 |
# File 'lib/ct_register_microservice/errors.rb', line 13 def ct_error_user_msg @ct_error_user_msg end |
#ct_error_user_title ⇒ Object
Returns the value of attribute ct_error_user_title.
13 14 15 |
# File 'lib/ct_register_microservice/errors.rb', line 13 def ct_error_user_title @ct_error_user_title end |
#http_status ⇒ Object
Returns the value of attribute http_status.
13 14 15 |
# File 'lib/ct_register_microservice/errors.rb', line 13 def http_status @http_status end |
#response_body ⇒ Object
Returns the value of attribute response_body.
13 14 15 |
# File 'lib/ct_register_microservice/errors.rb', line 13 def response_body @response_body end |