Exception: JSONAPI::Exceptions::TypeMismatch

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type) ⇒ TypeMismatch

Returns a new instance of TypeMismatch.


220
221
222
# File 'lib/jsonapi/exceptions.rb', line 220

def initialize(type)
  @type = type
end

Instance Attribute Details

#typeObject

Returns the value of attribute type


219
220
221
# File 'lib/jsonapi/exceptions.rb', line 219

def type
  @type
end

Instance Method Details

#errorsObject


224
225
226
227
228
229
230
231
# File 'lib/jsonapi/exceptions.rb', line 224

def errors
  [JSONAPI::Error.new(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