Merged
Conversation
- UnknownOperationException - MissingFieldException Co-authored-by: sihe <[email protected]>
This adds the failed operation and the actual value that failed the test operation check to the exception.
Replace all occurences of the generic Exception in JsonPointer with the more specific JsonPointerException so that the origin of the error is made explicit and can be handled by consuming code.
This exception is thrown in JsonPatch::apply whenever a JsonPointer call fails.
Codecov Report
@@ Coverage Diff @@
## master #57 +/- ##
==========================================
+ Coverage 96.63% 96.85% +0.22%
==========================================
Files 10 14 +4
Lines 535 573 +38
==========================================
+ Hits 517 555 +38
Misses 18 18
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
vearutop
approved these changes
Oct 21, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi again 👋
@Silvan-WMDE, @outdooracorn and I worked on the aforementioned improvements to
JsonPatcherrors. Here is what we did:JsonPatch::import()now throws aMissingFieldExceptionin case of a missing field. The exception contains the name of the missing field and the operation.JsonPatch::import()now throws aUnknownOperationExceptionin case of an unknown operation type. The exception contains the operation.PatchTestOperationFailedExceptionnow contains the failed operation and the value that caused the test operation to fail.JsonPatch::apply()now throws aPathExceptionin case anything is wrong with the path in a "path" or "from" field of an operation. The exception contains the name of the problematic field ("path" or "from") and the operation.JsonPointernow always throwsJsonPointerExceptioninstead of a genericException.This last point isn't really something we planned on doing, but it helped us in our implementation of the
PathExceptioncase above. We also considered an alternative approach in https://github.com/wmde/json-diff/pull/4/files that didn't require the introduction of aJsonPointerException. We'd be curious to hear your thoughts on it, or alternative ideas!The changes are fairly well split up into commits. Let me know if that works, or if you'd rather have the changes submitted individually or sliced differently.
Thanks! :)
Fixes #53.