File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,17 +18,18 @@ def rollback
1818 # Catch errors that should be handled before JSONAPI::Exceptions::Error
1919 # and other unprocessed exceptions
2020 def process_operation ( operation )
21- with_default_handling do
21+ with_default_handling do
2222 begin
2323 operation . apply
2424 rescue ActiveRecord ::DeleteRestrictionError => e
2525 record_locked_error = JSONAPI ::Exceptions ::RecordLocked . new ( e . message )
2626 return JSONAPI ::ErrorsOperationResult . new ( record_locked_error . errors [ 0 ] . code , record_locked_error . errors )
2727
2828 rescue ActiveRecord ::RecordNotFound
29- record_not_found = JSONAPI ::Exceptions ::RecordNotFound . new ( operation . associated_key )
29+ key = operation . respond_to? ( :associated_key ) ? operation . associated_key : :unavailable
30+ record_not_found = JSONAPI ::Exceptions ::RecordNotFound . new ( key )
3031 return JSONAPI ::ErrorsOperationResult . new ( record_not_found . errors [ 0 ] . code , record_not_found . errors )
3132 end
32- end
33+ end
3334 end
3435end
You can’t perform that action at this time.
0 commit comments