Exception: CobotClient::ResponseError
- Defined in:
- lib/cobot_client/errors.rb
Constant Summary collapse
- HTTP_CODE =
nil
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Class Method Summary collapse
Instance Method Summary collapse
- #http_body ⇒ Object
- #http_code ⇒ Object
-
#initialize(msg = nil, response: nil) ⇒ ResponseError
constructor
A new instance of ResponseError.
Constructor Details
#initialize(msg = nil, response: nil) ⇒ ResponseError
Returns a new instance of ResponseError.
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/cobot_client/errors.rb', line 19 def initialize(msg = nil, response: nil) @response = response super( [ "HTTP #{http_code}", msg ].compact.join(' - ') ) end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
11 12 13 |
# File 'lib/cobot_client/errors.rb', line 11 def response @response end |
Class Method Details
.build(msg = nil, response:) ⇒ Object
13 14 15 16 17 |
# File 'lib/cobot_client/errors.rb', line 13 def self.build(msg = nil, response:) RESPONSE_CODE_TO_ERROR_CLASS .fetch(response.code, self) .new(msg, response: response) end |
Instance Method Details
#http_body ⇒ Object
30 31 32 |
# File 'lib/cobot_client/errors.rb', line 30 def http_body @response&.body end |
#http_code ⇒ Object
34 35 36 |
# File 'lib/cobot_client/errors.rb', line 34 def http_code @response&.code || self.class.const_get(:HTTP_CODE) end |