Exception: ApiException
- Inherits:
-
StandardError
- Object
- StandardError
- ApiException
- Defined in:
- lib/PCP-server-Ruby-SDK/errors/api_exception.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#response_body ⇒ Object
readonly
Returns the value of attribute response_body.
-
#status_code ⇒ Object
readonly
Returns the value of attribute status_code.
Instance Method Summary collapse
-
#initialize(status_code, response_body, cause = nil) ⇒ ApiException
constructor
A new instance of ApiException.
- #message ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(status_code, response_body, cause = nil) ⇒ ApiException
Returns a new instance of ApiException.
4 5 6 7 8 9 |
# File 'lib/PCP-server-Ruby-SDK/errors/api_exception.rb', line 4 def initialize(status_code, response_body, cause = nil) super(response_body) @status_code = status_code @response_body = response_body set_backtrace(cause.backtrace) if cause end |
Instance Attribute Details
#response_body ⇒ Object (readonly)
Returns the value of attribute response_body.
2 3 4 |
# File 'lib/PCP-server-Ruby-SDK/errors/api_exception.rb', line 2 def response_body @response_body end |
#status_code ⇒ Object (readonly)
Returns the value of attribute status_code.
2 3 4 |
# File 'lib/PCP-server-Ruby-SDK/errors/api_exception.rb', line 2 def status_code @status_code end |
Instance Method Details
#message ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/PCP-server-Ruby-SDK/errors/api_exception.rb', line 15 def if .nil? msg = "Error message: the server returns an error" else msg = end msg += "\nHTTP status code: #{status_code}" if status_code msg += "\nResponse body: #{response_body}" if response_body msg end |
#to_s ⇒ Object
11 12 13 |
# File 'lib/PCP-server-Ruby-SDK/errors/api_exception.rb', line 11 def to_s end |