Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve HttpError Body Recording #218

Merged
merged 1 commit into from
Nov 28, 2024
Merged

Conversation

ludorival
Copy link
Owner

Description:
This pull request enhances the error handling mechanism in the pact-jvm-mockk plugin by improving the way HttpError responses are recorded. Key changes include:

  1. Addition of anError Function:

    • Introduced a new helper function anError to throw a PactMockResponseError with a detailed response body.
    • This replaces the direct usage of HttpClientErrorException.
  2. Refactoring Interception Logic:

    • Refactored the interception logic by introducing interceptAndGet to ensure proper handling and returning of results or errors.
    • Simplifies the existing intercept method by delegating result handling to adapters.
  3. Enhancement in Adapter:

    • Enhanced SpringRestTemplateMockkAdapter to handle PactMockResponseError and construct HttpClientErrorException with detailed error information.
    • Supports both the original and detailed error handling seamlessly.
  4. Internal Changes:

    • Introduced errorResponse in PactMockKAnswerScope to capture error responses.
    • Added PactMockResponseError class to encapsulate error responses.

These changes aim to improve the expressiveness and clarity of HTTP error responses recorded during Pacts.

Type of Change:

  • Bug Fix
  • New Feature
  • Breaking Change
  • Non-Breaking Change
  • Documentation Update

Checklist:

  • Updated related documentation.
  • Refactored code to improve readability.
  • Added/updated unit tests to ensure the correctness of changes.
  • Ran the test suite and confirmed all tests are passing.

Please review the changes and provide feedback. Thank you!

@ludorival ludorival merged commit 9a82f70 into main Nov 28, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant