Exception: JSONAPI::Exceptions::InvalidField

Inherits:
Error
  • Object
show all
Defined in:
lib/jsonapi/exceptions.rb

Instance Attribute Summary collapse

Attributes inherited from Error

#error_object_overrides

Instance Method Summary collapse

Methods inherited from Error

#create_error_object

Constructor Details

#initialize(type, field, error_object_overrides = {}) ⇒ InvalidField

Returns a new instance of InvalidField.



313
314
315
316
317
# File 'lib/jsonapi/exceptions.rb', line 313

def initialize(type, field, error_object_overrides = {})
  @field = field
  @type = type
  super(error_object_overrides)
end

Instance Attribute Details

#fieldObject

Returns the value of attribute field.



311
312
313
# File 'lib/jsonapi/exceptions.rb', line 311

def field
  @field
end

#typeObject

Returns the value of attribute type.



311
312
313
# File 'lib/jsonapi/exceptions.rb', line 311

def type
  @type
end

Instance Method Details

#errorsObject



319
320
321
322
323
324
325
326
327
# File 'lib/jsonapi/exceptions.rb', line 319

def errors
  [create_error_object(code: JSONAPI::INVALID_FIELD,
                       status: :bad_request,
                       title: I18n.translate('jsonapi-resources.exceptions.invalid_field.title',
                                             default: 'Invalid field'),
                       detail: I18n.translate('jsonapi-resources.exceptions.invalid_field.detail',
                                              default: "#{field} is not a valid field for #{type}.",
                                              field: field, type: type))]
end