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