Exception: SphereEngine::Error
- Inherits:
-
StandardError
- Object
- StandardError
- SphereEngine::Error
- Defined in:
- lib/sphere_engine/error.rb
Overview
Custom error class for rescuing from all SphereEngine errors
Constant Summary collapse
- BadRequest =
ClientErrors(Raised when SphereEngine returns a 4xx HTTP status code)
Raised when SphereEngine returns the HTTP status code 400
Class.new(self)
Class.new(self)
- ERRORS =
{ 400 => SphereEngine::Error::BadRequest, 401 => SphereEngine::Error:: }
Instance Attribute Summary collapse
- #code ⇒ Integer readonly
Class Method Summary collapse
-
.from_response(body) ⇒ SphereEngine::Error
Create a new error from an HTTP response.
Instance Method Summary collapse
-
#initialize(message = '', code = nil) ⇒ SphereEngine::Error
constructor
Initializes a new Error object.
Constructor Details
#initialize(message = '', code = nil) ⇒ SphereEngine::Error
Initializes a new Error object
12 13 14 15 |
# File 'lib/sphere_engine/error.rb', line 12 def initialize( = '', code = nil) super() @code = code end |
Instance Attribute Details
#code ⇒ Integer (readonly)
5 6 7 |
# File 'lib/sphere_engine/error.rb', line 5 def code @code end |
Class Method Details
.from_response(body) ⇒ SphereEngine::Error
Create a new error from an HTTP response
36 37 38 39 |
# File 'lib/sphere_engine/error.rb', line 36 def from_response(body) , code = parse_error(body) new(, code) end |