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

feat: add interceptor for error responses #1646

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mojito317
Copy link
Contributor

PR summary

Add interceptor for error response augmentation

Fixes: s1003

PR Checklist

Please make sure that your PR fulfills the following requirements:

  • The commit message follows the
    Angular Commit Message Guidelines.
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • New tests
  • Build/CI related changes
  • Documentation content changes
  • Other (please describe)

What is the current behavior?

Cloudant/CouchDB error models are handled by the core with only the error field being processed. Obtaining e.g. the reason field requires additional user code.

What is the new behavior?

The error response is augmented with errors and trace properties.
This improves the way the core handles the error response and enhances the user facing exception string to include the reason.
The trace is the CouchDB request ID which can be used to correlate with logs.

Does this PR introduce a breaking change?

  • Yes
  • No
    The existing error model fields are retained, the new fields are backwards compatible.

Other information

Add errorResponseInterceptor.
Modify cloudantBaseService to apply interceptor.
New tests in errorResponseInterceptorTest.
Fix service options on test/unit/features/testDataProviders.js.
Add nock for testing.

@mojito317 mojito317 self-assigned this Oct 17, 2024
@mojito317 mojito317 requested a review from a team as a code owner October 17, 2024 15:44
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