swaggest / json-diff

JSON diff/rearrange/patch/pointer library for PHP
MIT License
220 stars 30 forks source link

Improve JsonPatch exceptions #53

Closed jakobw closed 2 years ago

jakobw commented 2 years ago

Hi! :wave:

As mentioned in #49 we (@wmde) are using json-diff in the context of a PATCH endpoint in our REST API. We realized that some changes to the exceptions thrown by JsonPatch would allow us to provide more helpful error responses to our users.

The concrete improvements we're thinking of are:

1) More exception types for different types of errors (similar to #49), e.g. some sort of MissingFieldException and InvalidOperationException thrown by JsonPatch::import() to tell the two error cases apart 2) Include details about the error in the exception if possible. For most (all?) error cases would be the failed operation (related to #45), but potentially also additional information, e.g. the actual value that caused a test operation to fail.

If this generally sound useful, we'd be happy to submit a PR.

vearutop commented 2 years ago

Hi, this definitely sounds like an improvement and I'd be happy to accept a PR for that. 👍