class Gruf::Errors::Field
Represents a field-specific error
Attributes
error_code[R]
@return [Symbol] The application error code for the field, e.g. :job_not_found
field_name[R]
@return [Symbol] The name of the field as a Symbol
message[R]
@return [String] The error message for the field, e.g. “Job with ID 123 not found”
Public Class Methods
new(field_name, error_code, message = '')
click to toggle source
@param [Symbol] field_name
The name of the field as a Symbol @param [Symbol] error_code
The application error code for the field, e.g. :job_not_found @param [String] message (Optional) The error message for the field, e.g. “Job with ID 123 not found”
# File lib/gruf/errors/field.rb, line 36 def initialize(field_name, error_code, message = '') @field_name = field_name @error_code = error_code @message = message end
Public Instance Methods
to_h()
click to toggle source
Return the field error represented as a hash
@return [Hash] The error represented as a hash
# File lib/gruf/errors/field.rb, line 47 def to_h { field_name: field_name, error_code: error_code, message: message } end