-
Notifications
You must be signed in to change notification settings - Fork 14
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
Conversation
There was a problem hiding this 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.
canopeum_frontend/src/components/analytics/site-modal/SiteModal.tsx
Outdated
Show resolved
Hide resolved
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. |
Make sure that the code wasn't copied from elsewhere (check one):
Add catch to unhandled promises and display error messages for related errors
Closes #331