Exception: JSONAPI::Exceptions::UnsupportedMediaTypeError

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(media_type, error_object_overrides = {}) ⇒ UnsupportedMediaTypeError

Returns a new instance of UnsupportedMediaTypeError.



107
108
109
110
# File 'lib/jsonapi/exceptions.rb', line 107

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

Instance Attribute Details

#media_typeObject

Returns the value of attribute media_type.



105
106
107
# File 'lib/jsonapi/exceptions.rb', line 105

def media_type
  @media_type
end

Instance Method Details

#errorsObject



112
113
114
115
116
117
118
119
120
121
# File 'lib/jsonapi/exceptions.rb', line 112

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