stefankoegl/python-json-patch — pull request #27 by umago (2014-04-07 13:35:09+00:00)
Title: Improve error message when removing non-existent objects

The message before wasn't very intuitive :)

In [6]: doc = {'a': 1, 'b': 2}

In [7]: jsonpatch.apply_patch(doc, jsonpatch.JsonPatch(patch))
---------------------------------------------------------------------------
JsonPatchConflict Traceback (most recent call last)
in ()
----> 1 jsonpatch.apply_patch(doc, jsonpatch.JsonPatch(patch))

/usr/lib/python2.7/site-packages/jsonpatch.pyc in apply_patch(doc, patch, in_place)
140 else:
141 patch = JsonPatch(patch)
--> 142 return patch.apply(doc, in_place)
143
144

/usr/lib/python2.7/site-packages/jsonpatch.pyc in apply(self, obj, in_place)
336
337 for operation in self._ops:
--> 338 obj = operation.apply(obj)
339
340 return obj

/usr/lib/python2.7/site-packages/jsonpatch.pyc in apply(self, obj)
388 del subobj[part]
389 except (KeyError, IndexError) as ex:
--> 390 raise JsonPatchConflict(str(ex))
391
392 return obj

JsonPatchConflict: u'c'