@@ -18,9 +18,9 @@ def errors
1818
1919 [ JSONAPI ::Error . new ( code : JSONAPI ::INTERNAL_SERVER_ERROR ,
2020 status : :internal_server_error ,
21- title : I18n . t ( 'jsonapi-resources.exceptions.internal_server_error.title' ,
21+ title : I18n . t ( 'jsonapi-resources.exceptions.internal_server_error.title' ,
2222 default : 'Internal Server Error' ) ,
23- detail : I18n . t ( 'jsonapi-resources.exceptions.internal_server_error.detail' ,
23+ detail : I18n . t ( 'jsonapi-resources.exceptions.internal_server_error.detail' ,
2424 default : 'Internal Server Error' ) ,
2525 meta : meta ) ]
2626 end
@@ -35,9 +35,9 @@ def initialize(resource)
3535 def errors
3636 [ JSONAPI ::Error . new ( code : JSONAPI ::INVALID_RESOURCE ,
3737 status : :bad_request ,
38- title : I18n . t ( 'jsonapi-resources.exceptions.invalid_resource.title' ,
38+ title : I18n . t ( 'jsonapi-resources.exceptions.invalid_resource.title' ,
3939 default : 'Invalid resource' ) ,
40- detail : I18n . t ( 'jsonapi-resources.exceptions.invalid_resource.detail' ,
40+ detail : I18n . t ( 'jsonapi-resources.exceptions.invalid_resource.detail' ,
4141 default : "#{ resource } is not a valid resource." , resource : resource ) ) ]
4242 end
4343 end
@@ -51,9 +51,9 @@ def initialize(id)
5151 def errors
5252 [ JSONAPI ::Error . new ( code : JSONAPI ::RECORD_NOT_FOUND ,
5353 status : :not_found ,
54- title : I18n . translate ( 'jsonapi-resources.exceptions.record_not_found.title' ,
54+ title : I18n . translate ( 'jsonapi-resources.exceptions.record_not_found.title' ,
5555 default : 'Record not found' ) ,
56- detail : I18n . translate ( 'jsonapi-resources.exceptions.record_not_found.detail' ,
56+ detail : I18n . translate ( 'jsonapi-resources.exceptions.record_not_found.detail' ,
5757 default : "The record identified by #{ id } could not be found." , id : id ) ) ]
5858 end
5959 end
@@ -67,7 +67,7 @@ def initialize(media_type)
6767 def errors
6868 [ JSONAPI ::Error . new ( code : JSONAPI ::UNSUPPORTED_MEDIA_TYPE ,
6969 status : :unsupported_media_type ,
70- title : I18n . translate ( 'jsonapi-resources.exceptions.unsupported_media_type.title' ,
70+ title : I18n . translate ( 'jsonapi-resources.exceptions.unsupported_media_type.title' ,
7171 default : 'Unsupported media type' ) ,
7272 detail : I18n . translate ( 'jsonapi-resources.exceptions.unsupported_media_type.detail' ,
7373 default : "All requests that create or update must use the '#{ JSONAPI ::MEDIA_TYPE } ' Content-Type. This request specified '#{ media_type } '." ,
@@ -76,6 +76,26 @@ def errors
7676 end
7777 end
7878
79+ class NotAcceptableError < Error
80+ attr_accessor :media_type
81+
82+ def initialize ( media_type )
83+ @media_type = media_type
84+ end
85+
86+ def errors
87+ [ JSONAPI ::Error . new ( code : JSONAPI ::NOT_ACCEPTABLE ,
88+ status : :not_acceptable ,
89+ title : I18n . translate ( 'jsonapi-resources.exceptions.not_acceptable.title' ,
90+ default : 'Not acceptable' ) ,
91+ detail : I18n . translate ( 'jsonapi-resources.exceptions.not_acceptable.detail' ,
92+ default : "All requests must use the '#{ JSONAPI ::MEDIA_TYPE } ' Accept without media type parameters. This request specified '#{ media_type } '." ,
93+ needed_media_type : JSONAPI ::MEDIA_TYPE ,
94+ media_type : media_type ) ) ]
95+ end
96+ end
97+
98+
7999 class HasManyRelationExists < Error
80100 attr_accessor :id
81101 def initialize ( id )
@@ -85,7 +105,7 @@ def initialize(id)
85105 def errors
86106 [ JSONAPI ::Error . new ( code : JSONAPI ::RELATION_EXISTS ,
87107 status : :bad_request ,
88- title : I18n . translate ( 'jsonapi-resources.exceptions.has_many_relation.title' ,
108+ title : I18n . translate ( 'jsonapi-resources.exceptions.has_many_relation.title' ,
89109 default : 'Relation exists' ) ,
90110 detail : I18n . translate ( 'jsonapi-resources.exceptions.has_many_relation.detail' ,
91111 default : "The relation to #{ id } already exists." ,
@@ -97,7 +117,7 @@ class ToManySetReplacementForbidden < Error
97117 def errors
98118 [ JSONAPI ::Error . new ( code : JSONAPI ::FORBIDDEN ,
99119 status : :forbidden ,
100- title : I18n . translate ( 'jsonapi-resources.exceptions.to_many_set_replacement_forbidden.title' ,
120+ title : I18n . translate ( 'jsonapi-resources.exceptions.to_many_set_replacement_forbidden.title' ,
101121 default : 'Complete replacement forbidden' ) ,
102122 detail : I18n . translate ( 'jsonapi-resources.exceptions.to_many_set_replacement_forbidden.detail' ,
103123 default : 'Complete replacement forbidden for this relationship' ) ) ]
0 commit comments