zjsonpatch icon indicating copy to clipboard operation
zjsonpatch copied to clipboard

Provide a separate exception when a test operation fails

Open turing85 opened this issue 11 months ago β€’ 3 comments

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.

turing85 avatar Jan 11 '25 00:01 turing85

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_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. πŸ“ Description β€” Summarize the main change in 50–60 words, explaining what was done.
  2. πŸ““ References β€” List relevant issues, discussions, documentation, or related PRs.
  3. πŸ“¦ Dependencies & Requirements β€” Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. πŸ“Š Contributor Summary β€” Include a Markdown table showing contributions: | Contributor | Lines Added | Lines Removed | Files Changed |
  5. βœ”οΈ 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.

❀️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Nov 19 '25 20:11 coderabbitai[bot]

Do we want to merge this PR or nah?

turing85 avatar Nov 19 '25 20:11 turing85

Anybody?

turing85 avatar Dec 09 '25 17:12 turing85

Apologies @turing85 for the delay.

vishwakarma avatar Dec 15 '25 19:12 vishwakarma