Exception: JSONAPI::Exceptions::TypeMismatch

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, error_object_overrides = {}) ⇒ TypeMismatch

Returns a new instance of TypeMismatch.



295
296
297
298
# File 'lib/jsonapi/exceptions.rb', line 295

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

Instance Attribute Details

#typeObject

Returns the value of attribute type.



293
294
295
# File 'lib/jsonapi/exceptions.rb', line 293

def type
  @type
end

Instance Method Details

#errorsObject



300
301
302
303
304
305
306
307
# File 'lib/jsonapi/exceptions.rb', line 300

def errors
  [create_error_object(code: JSONAPI::TYPE_MISMATCH,
                       status: :bad_request,
                       title: I18n.translate('jsonapi-resources.exceptions.type_mismatch.title',
                                             default: 'Type Mismatch'),
                       detail: I18n.translate('jsonapi-resources.exceptions.type_mismatch.detail',
                                              default: "#{type} is not a valid type for this operation.", type: type))]
end