Exception: JSONAPI::Exceptions::UnsupportedMediaTypeError

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(media_type) ⇒ UnsupportedMediaTypeError

Returns a new instance of UnsupportedMediaTypeError.



35
36
37
# File 'lib/jsonapi/exceptions.rb', line 35

def initialize(media_type)
  @media_type = media_type
end

Instance Attribute Details

#media_typeObject

Returns the value of attribute media_type.



34
35
36
# File 'lib/jsonapi/exceptions.rb', line 34

def media_type
  @media_type
end

Instance Method Details

#errorsObject



39
40
41
42
43
44
# File 'lib/jsonapi/exceptions.rb', line 39

def errors
  [JSONAPI::Error.new(code: JSONAPI::UNSUPPORTED_MEDIA_TYPE,
                       status: :unsupported_media_type,
                       title: 'Unsupported media type',
                       detail: "All requests that create or update resources must use the '#{JSONAPI::MEDIA_TYPE}' Content-Type. This request specified '#{media_type}.'")]
end