Exception: Virtuatable::API::Errors::Base
- Inherits:
-
StandardError
- Object
- StandardError
- Virtuatable::API::Errors::Base
- Defined in:
- lib/virtuatable/api/errors/base.rb
Overview
Standard class parent to all specialized http errors.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#action ⇒ String
The name of the action the user was trying to perform on the model (often crate or update).
-
#error ⇒ String
The label of the error returned by the model.
-
#field ⇒ String, Symbol
The name of the field in error in the model.
-
#status ⇒ Integer
The HTTP status code as a number (eg: 400, 422 or 500).
Instance Method Summary collapse
-
#initialize(field:, error:, status:) ⇒ Base
constructor
A new instance of Base.
-
#message ⇒ String
Returns the formatted message for this exception.
Constructor Details
#initialize(field:, error:, status:) ⇒ Base
Returns a new instance of Base.
22 23 24 25 26 |
# File 'lib/virtuatable/api/errors/base.rb', line 22 def initialize(field:, error:, status:) @field = field.to_s @error = error @status = status end |
Instance Attribute Details
#action ⇒ String
Returns the name of the action the user was trying to perform on the model (often crate or update).
14 15 16 |
# File 'lib/virtuatable/api/errors/base.rb', line 14 def action @action end |
#error ⇒ String
Returns the label of the error returned by the model.
17 18 19 |
# File 'lib/virtuatable/api/errors/base.rb', line 17 def error @error end |
#field ⇒ String, Symbol
Returns the name of the field in error in the model.
11 12 13 |
# File 'lib/virtuatable/api/errors/base.rb', line 11 def field @field end |
#status ⇒ Integer
Returns the HTTP status code as a number (eg: 400, 422 or 500).
20 21 22 |
# File 'lib/virtuatable/api/errors/base.rb', line 20 def status @status end |
Instance Method Details
#message ⇒ String
Returns the formatted message for this exception.
30 31 32 |
# File 'lib/virtuatable/api/errors/base.rb', line 30 def "#{field}.#{error}" end |