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/handle all promises #335

Merged
merged 7 commits into from
Jan 24, 2025
Merged

Conversation

maximeBAY
Copy link
Collaborator

@maximeBAY maximeBAY commented Dec 19, 2024

  • The project passes automated tests locally (build, linting, etc.).
  • You updated the project's documentation with new changes.
  • You've linked any issue this PR closes
  • You reviewed your own PR and made sure there's no test/debug code or any obvious mistakes.

Make sure that the code wasn't copied from elsewhere (check one):

  • This is your own original code
  • [] You have made sure that we have permission to use the copied code and that we follow its licensing

Add catch to unhandled promises and display error messages for related errors

Closes #331

Copy link
Contributor

@Samuel-Therrien-Beslogic Samuel-Therrien-Beslogic left a comment

Choose a reason for hiding this comment

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

I see a ton of repetition of the API error handling, how about we create a helper method we can pass to .catch?

  const displayUnhandledAPIError = (
    fallbackMessageTranslationKey: string,
    translationOptions?: Record<string, string | undefined>,
  ) =>
  (error: unknown) =>
    openAlertSnackbar(
      getErrorMessage(error, translate(fallbackMessageTranslationKey, translationOptions)),
      { severity: 'error' },
    )

I'm working on a PR to your PR, incoming in a moment.

@Samuel-Therrien-Beslogic
Copy link
Contributor

Oh it's failing because top-level awaits is not available on all browsers we target. Either we should reconfigure that to target only more modern browsers, or the i18n top-level await can go back to being a voided promise with an eslint-disable comment explaining why we can't use a top-level await.

@Samuel-Therrien-Beslogic Samuel-Therrien-Beslogic merged commit fc8d68f into main Jan 24, 2025
2 checks passed
@Samuel-Therrien-Beslogic Samuel-Therrien-Beslogic deleted the feat/handle-all-promises branch January 24, 2025 17:24
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.

All promises should be handled
2 participants