Exception: JSONAPI::Exceptions::NotAcceptableError

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(media_type) ⇒ NotAcceptableError


82
83
84
# File 'lib/jsonapi/exceptions.rb', line 82

def initialize(media_type)
  @media_type = media_type
end

Instance Attribute Details

#media_typeObject

Returns the value of attribute media_type


80
81
82
# File 'lib/jsonapi/exceptions.rb', line 80

def media_type
  @media_type
end

Instance Method Details

#errorsObject


86
87
88
89
90
91
92
93
94
95
# File 'lib/jsonapi/exceptions.rb', line 86

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