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

UISACQCOMP-219 Create common utilities for managing response errors #817

Merged
merged 3 commits into from
Oct 7, 2024

Conversation

usavkov-epam
Copy link
Contributor

@usavkov-epam usavkov-epam commented Oct 3, 2024

Purpose

https://folio-org.atlassian.net/browse/UISACQCOMP-219

  • The ResponseErrorsContainer utility is designed to handle and manage errors that arise from HTTP responses in a structured way.
  • It standardizes errors into a manageable format, regardless of whether the error comes in a specific format or is generic/unknown.
  • It allows easy retrieval of error messages, codes, and handling via various strategies to streamline error processing.
  • The utility simplifies working with multiple errors by storing them in a structured format, such as a Map.

Approach

  1. The class encapsulates the original HTTP response and parses the response body, particularly focusing on extracting errors.
  2. It provides both static and instance methods to:
    • Parse errors, normalize them, and store them in a map for quick access.
    • Offer error retrieval by code or default to the first error if no specific code is provided.
    • Enable integration with external strategies for customized error handling.
  3. It supports asynchronous creation of error containers, making it adaptable to promise-based response handling.
  4. The utility normalizes different types of errors (e.g., strings, JSON objects) into a consistent structure using the ResponseErrorContainer class for downstream usage.

Pre-Merge Checklist

Before merging this PR, please go through the following list and take appropriate actions.

  • I've added appropriate record to the CHANGELOG.md
  • Does this PR meet or exceed the expected quality standards?
    • Code coverage on new code is 80% or greater
    • Duplications on new code is 3% or less
    • There are no major code smells or security issues
  • Does this introduce breaking changes?
    • If any API-related changes - okapi interfaces and permissions are reviewed/changed correspondingly
    • There are no breaking changes in this PR.

If there are breaking changes, please STOP and consider the following:

  • What other modules will these changes impact?
  • Do JIRAs exist to update the impacted modules?
    • If not, please create them
    • Do they contain the appropriate level of detail? Which endpoints/schemas changed, etc.
    • Do they have all they appropriate links to blocked/related issues?
  • Are the JIRAs under active development?
    • If not, contact the project's PO and make sure they're aware of the urgency.
  • Do PRs exist for these changes?
    • If so, have they been approved?

Ideally all of the PRs involved in breaking changes would be merged in the same day to avoid breaking the folio-testing environment. Communication is paramount if that is to be achieved, especially as the number of intermodule and inter-team dependencies increase.

While it's helpful for reviewers to help identify potential problems, ensuring that it's safe to merge is ultimately the responsibility of the PR assignee.

@usavkov-epam usavkov-epam self-assigned this Oct 3, 2024
Copy link

github-actions bot commented Oct 3, 2024

Jest Unit Test Statistics

    1 files  ±  0  214 suites  +2   3m 58s ⏱️ -5s
556 tests +20  554 ✔️ +20  2 💤 ±0  0 ±0 
559 runs  +20  557 ✔️ +20  2 💤 ±0  0 ±0 

Results for commit fb67eb2. ± Comparison against base commit d0dde18.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Oct 3, 2024

BigTest Unit Test Statistics

0 tests  ±0   0 ✔️ ±0   0s ⏱️ ±0s
0 suites ±0   0 💤 ±0 
0 files   ±0   0 ±0 

Results for commit fb67eb2. ± Comparison against base commit d0dde18.

♻️ This comment has been updated with latest results.

@usavkov-epam usavkov-epam requested review from a team October 3, 2024 13:01

import { ERROR_CODE_GENERIC } from '../../constants';
import { ResponseErrorsContainer } from './ResponseErrorsContainer';
import { ResponseErrorContainer } from './ResponseErrorContainer';
Copy link
Contributor

Choose a reason for hiding this comment

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

It is not a big deal but you could change the order 1 line up ⬆️

Copy link

sonarqubecloud bot commented Oct 7, 2024

@usavkov-epam usavkov-epam merged commit 161e664 into master Oct 7, 2024
6 checks passed
@usavkov-epam usavkov-epam deleted the UISACQCOMP-219 branch October 7, 2024 05:46
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