Exception: Kabk::ApiError
- Inherits:
-
StandardError
- Object
- StandardError
- Kabk::ApiError
- Defined in:
- lib/kabk/errors.rb
Overview
Defines standardized API errors that map to protocol error codes
Direct Known Subclasses
ConcurrencyConflictError, ForbiddenError, InvalidOldPasswordError, NotFoundError, UnauthorizedError, ValidationError
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
-
#http_status ⇒ Object
readonly
Returns the value of attribute http_status.
Instance Method Summary collapse
-
#initialize(message, code: "SERVER_ERROR", http_status: 500, fields: {}) ⇒ ApiError
constructor
A new instance of ApiError.
- #to_h ⇒ Object
Constructor Details
#initialize(message, code: "SERVER_ERROR", http_status: 500, fields: {}) ⇒ ApiError
Returns a new instance of ApiError.
8 9 10 11 12 13 |
# File 'lib/kabk/errors.rb', line 8 def initialize(, code: "SERVER_ERROR", http_status: 500, fields: {}) super() @code = code @http_status = http_status @fields = fields end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
6 7 8 |
# File 'lib/kabk/errors.rb', line 6 def code @code end |
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
6 7 8 |
# File 'lib/kabk/errors.rb', line 6 def fields @fields end |
#http_status ⇒ Object (readonly)
Returns the value of attribute http_status.
6 7 8 |
# File 'lib/kabk/errors.rb', line 6 def http_status @http_status end |
Instance Method Details
#to_h ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/kabk/errors.rb', line 15 def to_h { success: false, error: { code: @code, message: , fields: @fields } } end |