Exception: Ubicloud::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Ubicloud::Error
- Defined in:
- lib/ubicloud.rb
Overview
Error class used for errors raised by Ubicloud’s Ruby SDK.
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
The integer HTTP status code related to the error.
Instance Method Summary collapse
-
#initialize(message, code: nil, body: nil) ⇒ Error
constructor
Accept the code and body keyword arguments for metadata related to this error.
-
#params ⇒ Object
A hash of parameters.
Constructor Details
#initialize(message, code: nil, body: nil) ⇒ Error
Accept the code and body keyword arguments for metadata related to this error.
22 23 24 25 26 |
# File 'lib/ubicloud.rb', line 22 def initialize(, code: nil, body: nil) super() @code = code @body = body end |
Instance Attribute Details
#code ⇒ Object (readonly)
The integer HTTP status code related to the error. Can be nil if the Error is not related to an HTTP request.
18 19 20 |
# File 'lib/ubicloud.rb', line 18 def code @code end |
Instance Method Details
#params ⇒ Object
A hash of parameters. This is the parsed JSON response body for the request that resulted in an error. If an invalid body is given, or the error is not related to an HTTP request, returns an empty hash.
32 33 34 35 36 |
# File 'lib/ubicloud.rb', line 32 def params @body ? JSON.parse(@body) : {} rescue {} end |