Exception: PCPServerSDK::Errors::ApiException
- Inherits:
-
StandardError
- Object
- StandardError
- PCPServerSDK::Errors::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
The constructor.
- #message ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(status_code, response_body, cause = nil) ⇒ ApiException
The constructor
12 13 14 15 16 17 |
# File 'lib/PCP-server-Ruby-SDK/errors/api_exception.rb', line 12 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.
6 7 8 |
# File 'lib/PCP-server-Ruby-SDK/errors/api_exception.rb', line 6 def response_body @response_body end |
#status_code ⇒ Object (readonly)
Returns the value of attribute status_code.
6 7 8 |
# File 'lib/PCP-server-Ruby-SDK/errors/api_exception.rb', line 6 def status_code @status_code end |
Instance Method Details
#message ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/PCP-server-Ruby-SDK/errors/api_exception.rb', line 23 def if @message.nil? msg = "Error message: the server returns an error" else msg = @message end msg += "\nHTTP status code: #{status_code}" if status_code msg += "\nResponse body: #{response_body}" if response_body msg end |
#to_s ⇒ Object
19 20 21 |
# File 'lib/PCP-server-Ruby-SDK/errors/api_exception.rb', line 19 def to_s end |