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.
36 37 38 39 40 |
# File 'lib/gruf/errors/field.rb', line 36 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.
27 28 29 |
# File 'lib/gruf/errors/field.rb', line 27 def error_code @error_code end |
#field_name ⇒ Symbol (readonly)
Returns The name of the field as a Symbol.
25 26 27 |
# File 'lib/gruf/errors/field.rb', line 25 def field_name @field_name end |
#message ⇒ String (readonly)
Returns The error message for the field, e.g. “Job with ID 123 not found”.
29 30 31 |
# File 'lib/gruf/errors/field.rb', line 29 def @message end |
Instance Method Details
#to_h ⇒ Hash
Return the field error represented as a hash
47 48 49 50 51 52 53 |
# File 'lib/gruf/errors/field.rb', line 47 def to_h { field_name: field_name, error_code: error_code, message: } end |