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: improve error responses #719

Merged
merged 1 commit into from
Oct 30, 2024
Merged

feat: improve error responses #719

merged 1 commit into from
Oct 30, 2024

Conversation

ricellis
Copy link
Member

PR summary

Add event hook for error response augmentation

Fixes: s1004

Note: An existing issue is required before opening a PR.

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.
Exception strings will be different, but the types remain the same.

Other information

Create _error_response_hook function to augment
error messages.
Add hook to the client requests session.
Unit tests for the hook.

@ricellis ricellis self-assigned this Oct 17, 2024
@ricellis ricellis force-pushed the s1004-error-augmentation branch 3 times, most recently from 72970cd to d43f4f1 Compare October 21, 2024 14:53
@ricellis ricellis requested a review from a team as a code owner October 21, 2024 14:53
@ricellis ricellis force-pushed the s1004-error-augmentation branch from d43f4f1 to 110dc4a Compare October 21, 2024 16:26
Copy link
Contributor

@emlaver emlaver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! A couple comments

@ricellis ricellis force-pushed the s1004-error-augmentation branch from 110dc4a to 37c61ab Compare October 23, 2024 09:02
@ricellis ricellis force-pushed the s1004-error-augmentation branch from 37c61ab to 52782ad Compare October 29, 2024 14:43
Create _error_response_hook function to augment
error messages.
Add hook to the client requests session.
Unit tests for the hook.
@ricellis ricellis force-pushed the s1004-error-augmentation branch from 52782ad to 73e22c7 Compare October 29, 2024 17:54
@ricellis ricellis merged commit 309baaa into main Oct 30, 2024
10 checks passed
@ricellis ricellis deleted the s1004-error-augmentation branch October 30, 2024 17:02
@ricellis ricellis mentioned this pull request Nov 6, 2024
13 tasks
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.

3 participants