Provide a separate exception when a test operation fails
Resolves #200
Summary by CodeRabbit
- New Features
- JSON Patch test operations now throw a specialized exception type for test failures, enabling better distinction between test-related errors and other application exceptions for improved error handling and debugging.
βοΈ Tip: You can customize this high-level summary in your review settings.
Walkthrough
A new dedicated exception JsonPatchTestFailedException was introduced to distinguish failed test operations from other JSON Patch application errors. The InPlaceApplyProcessor now throws this exception when a test operation's evaluated value doesn't match the expected value. Test data was updated to reflect the new exception type.
Changes
| Cohort / File(s) | Summary |
|---|---|
New Exception Class src/main/java/com/flipkart/zjsonpatch/JsonPatchTestFailedException.java |
Added public exception class extending JsonPatchApplicationException with constructor accepting message and JsonPointer path; delegates to superclass with Operation.TEST. |
Test Operation Error Handling src/main/java/com/flipkart/zjsonpatch/InPlaceApplyProcessor.java |
Modified test path comparison logic to throw JsonPatchTestFailedException instead of JsonPatchApplicationException when evaluated value doesn't match expected value. |
Test Data Updates src/test/resources/testdata/test.json |
Added "type": "JsonPatchTestFailedException" field to error objects in test data; fixed end-of-file newline handling. |
Estimated code review effort
π― 2 (Simple) | β±οΈ ~10 minutes
JsonPatchTestFailedException.java: Straightforward new exception class with minimal logic; verify proper inheritance chain and constructor delegation.InPlaceApplyProcessor.java: Verify exception throw locations align with test failure scenarios and confirm exception constructor signature matches usage.test.json: Confirm updated exception type names match the new class and all affected test cases are covered.
Poem
π° A test that fails now speaks its name, No more confusion, no more shame! JsonPatchTestFailedException clear, Distinguishes errors, far from near. Exceptions bloom with purpose true, Better debugging for me and you! πΏ
Pre-merge checks and finishing touches
β Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | β οΈ Warning | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. | You can run @coderabbitai generate docstrings to improve docstring coverage. |
β Passed checks (4 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | β Passed | Check skipped - CodeRabbitβs high-level summary is enabled. |
| Title check | β Passed | The title accurately describes the main change: introducing a separate exception type when test operations fail, which matches the core objective of the PR. |
| Linked Issues check | β Passed | The PR implements all coding requirements from issue #200: creates JsonPatchTestFailedException as a JsonPatchApplicationException subtype, updates InPlaceApplyProcessor to throw it for failed tests, and updates test data accordingly. |
| Out of Scope Changes check | β Passed | All changes are directly aligned with the scope of issue #200: new exception class, updated exception handling in the test operation logic, and corresponding test data updates. |
β¨ Finishing touches
- [ ] π Generate docstrings
π§ͺ Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
[!TIP]
π Customizable high-level summaries are now available in beta!
You can now customize how CodeRabbit generates the high-level summary in your pull requests β including its content, structure, tone, and formatting.
- Provide your own instructions using the
high_level_summary_instructionssetting.- Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
- Use
high_level_summary_in_walkthroughto move the summary from the description to the walkthrough section.Example instruction:
"Divide the high-level summary into five sections:
- π Description β Summarize the main change in 50β60 words, explaining what was done.
- π References β List relevant issues, discussions, documentation, or related PRs.
- π¦ Dependencies & Requirements β Mention any new/updated dependencies, environment variable changes, or configuration updates.
- π Contributor Summary β Include a Markdown table showing contributions:
| Contributor | Lines Added | Lines Removed | Files Changed |- βοΈ Additional Notes β Add any extra reviewer context. Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.
Do we want to merge this PR or nah?
Anybody?
Apologies @turing85 for the delay.