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.



315
316
317
318
319
# File 'lib/jsonapi/exceptions.rb', line 315

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.



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

def field
  @field
end

#typeObject

Returns the value of attribute type.



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

def type
  @type
end

Instance Method Details

#errorsObject



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

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