Exception: Sink::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Sink::Error
- Defined in:
- lib/sink/error.rb,
lib/sink/error.rb
Direct Known Subclasses
Conflict, ConnectionError, Forbidden, NotFound, RateLimited, ServerError, StorageNotReady, Unauthorized, ValidationError
Constant Summary collapse
- STATUS_ERRORS =
{ 400 => ValidationError, 401 => Unauthorized, 403 => Forbidden, 404 => NotFound, 409 => Conflict, 422 => ValidationError, 423 => StorageNotReady, 429 => RateLimited }.freeze
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Class Method Summary collapse
Instance Method Summary collapse
- #data ⇒ Object
-
#initialize(message = nil, status: nil, body: nil) ⇒ Error
constructor
A new instance of Error.
Constructor Details
#initialize(message = nil, status: nil, body: nil) ⇒ Error
Returns a new instance of Error.
12 13 14 15 16 |
# File 'lib/sink/error.rb', line 12 def initialize( = nil, status: nil, body: nil) @status = status @body = body super() end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
5 6 7 |
# File 'lib/sink/error.rb', line 5 def body @body end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
5 6 7 |
# File 'lib/sink/error.rb', line 5 def status @status end |
Class Method Details
.for(status:, message:, body: nil) ⇒ Object
7 8 9 10 |
# File 'lib/sink/error.rb', line 7 def self.for(status:, message:, body: nil) klass = STATUS_ERRORS[status] || (status.to_i >= 500 ? ServerError : self) klass.new(, status: status, body: body) end |
Instance Method Details
#data ⇒ Object
18 |
# File 'lib/sink/error.rb', line 18 def data = body.is_a?(Hash) ? body["data"] : nil |