Class: Gruf::Errors::Field
- Inherits:
-
Object
- Object
- Gruf::Errors::Field
- Defined in:
- lib/gruf/errors/field.rb
Overview
Represents a field-specific error
Instance Attribute Summary collapse
-
#error_code ⇒ Symbol
readonly
The application error code for the field, e.g.
-
#field_name ⇒ Symbol
readonly
The name of the field as a Symbol.
-
#message ⇒ String
readonly
The error message for the field, e.g.
Instance Method Summary collapse
-
#initialize(field_name, error_code, message = '') ⇒ Field
constructor
A new instance of Field.
-
#to_h ⇒ Hash
Return the field error represented as a hash.
Constructor Details
#initialize(field_name, error_code, message = '') ⇒ Field
Returns a new instance of Field.
34 35 36 37 38 |
# File 'lib/gruf/errors/field.rb', line 34 def initialize(field_name, error_code, = '') @field_name = field_name @error_code = error_code @message = end |
Instance Attribute Details
#error_code ⇒ Symbol (readonly)
Returns The application error code for the field, e.g. :job_not_found.
25 26 27 |
# File 'lib/gruf/errors/field.rb', line 25 def error_code @error_code end |
#field_name ⇒ Symbol (readonly)
Returns The name of the field as a Symbol.
23 24 25 |
# File 'lib/gruf/errors/field.rb', line 23 def field_name @field_name end |
#message ⇒ String (readonly)
Returns The error message for the field, e.g. “Job with ID 123 not found”.
27 28 29 |
# File 'lib/gruf/errors/field.rb', line 27 def @message end |
Instance Method Details
#to_h ⇒ Hash
Return the field error represented as a hash
45 46 47 48 49 50 51 |
# File 'lib/gruf/errors/field.rb', line 45 def to_h { field_name: field_name, error_code: error_code, message: } end |