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

Fetch error handing revisited #8081

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft

Conversation

jackkav
Copy link
Contributor

@jackkav jackkav commented Oct 15, 2024

motivation: inconsistency in how the fetch errors were being parsed and evaluated, eg json is parsed twice in order to get the error message in one place but not another.

goal: type the output of insomniaFetch when a known backend error message is returned, and flatten the try catch if else nesting complexity of insomniaFetch

options:

  1. use a custom Error type, with both message and errorType eg ResponseFailError but with more
  2. return Promise<T> | Promise<{message:string,errorType:string}>
  3. return an Error/ErrorCause with the api error within

This PR is meant to push this discussion with: @yaoweiprc @gatzjames

Using the exception and wrapping it has some rough edges in nodejs/chromium space because they dont both have error cause implementations.

TODO:

  • discuss error typing options with api team
  • standardise the way we deal with these within the app and website at a function typing level

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