Exception: JSONAPI::Exceptions::NotAcceptableError

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 = {}) ⇒ NotAcceptableError

Returns a new instance of NotAcceptableError.



127
128
129
130
# File 'lib/jsonapi/exceptions.rb', line 127

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.



125
126
127
# File 'lib/jsonapi/exceptions.rb', line 125

def media_type
  @media_type
end

Instance Method Details

#errorsObject



132
133
134
135
136
137
138
139
140
141
# File 'lib/jsonapi/exceptions.rb', line 132

def errors
  [create_error_object(code: JSONAPI::NOT_ACCEPTABLE,
                       status: :not_acceptable,
                       title: I18n.translate('jsonapi-resources.exceptions.not_acceptable.title',
                                             default: 'Not acceptable'),
                       detail: I18n.translate('jsonapi-resources.exceptions.not_acceptable.detail',
                                              default: "All requests must use the '#{JSONAPI::MEDIA_TYPE}' Accept without media type parameters. This request specified '#{media_type}'.",
                                              needed_media_type: JSONAPI::MEDIA_TYPE,
                                              media_type: media_type))]
end