-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: error boundary work in progress, requires graasp/graasp-ui#756 * chore(deps): graasp-ui to 4.10.0
- Loading branch information
Showing
6 changed files
with
206 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,20 @@ | ||
{ | ||
"translations": { | ||
"Welcome to the Graasp App Starter Kit": "Welcome to the Graasp App Starter Kit" | ||
"Welcome to the Graasp App Starter Kit": "Welcome to the Graasp App Starter Kit", | ||
"ERROR_BOUNDARY": { | ||
"FALLBACK": { | ||
"MESSAGE_TITLE": "Sorry, something went wrong with this application", | ||
"MESSAGE_FEEDBACK": "Our team has been notified. If you would like to help, please, tell us what happened below.", | ||
"ERROR_DETAILS": "Details of the error", | ||
"NAME_LABEL": "Name", | ||
"NAME_HELPER": "Provide your name (optional)", | ||
"EMAIL_LABEL": "Email", | ||
"EMAIL_HELPER": "Provide your email (optional)", | ||
"COMMENT_LABEL": "Comment", | ||
"COMMENT_HELPER": "Tell us what happened (optional)", | ||
"THANKS_FOR_FEEDBACK": "Thank you for your feedback!", | ||
"SEND": "Send your feedback" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { FC, ReactNode } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
import { ErrorFallback } from '@graasp/ui/apps'; | ||
|
||
import * as Sentry from '@sentry/react'; | ||
|
||
const ErrorBoundary: FC<{ children?: ReactNode }> = ({ children }) => { | ||
const { t: tFallback } = useTranslation('translations', { | ||
keyPrefix: 'ERROR_BOUNDARY.FALLBACK', | ||
}); | ||
return ( | ||
<Sentry.ErrorBoundary | ||
// eslint-disable-next-line react/no-unstable-nested-components | ||
fallback={({ error, componentStack, eventId }) => ( | ||
<ErrorFallback | ||
error={error} | ||
componentStack={componentStack} | ||
eventId={eventId} | ||
captureUserFeedback={Sentry.captureUserFeedback} | ||
title={tFallback('MESSAGE_TITLE')} | ||
formTitle={tFallback('MESSAGE_FEEDBACK')} | ||
nameLabel={tFallback('NAME_LABEL')} | ||
nameHelper={tFallback('NAME_HELPER')} | ||
emailLabel={tFallback('EMAIL_LABEL')} | ||
emailHelper={tFallback('EMAIL_HELPER')} | ||
commentLabel={tFallback('COMMENT_LABEL')} | ||
commentHelper={tFallback('COMMENT_HELPER')} | ||
thanksMessage={tFallback('THANKS_FOR_FEEDBACK')} | ||
sendButtonLabel={tFallback('SEND')} | ||
errorDetailsLabel={tFallback('ERROR_DETAILS')} | ||
/> | ||
)} | ||
> | ||
{children} | ||
</Sentry.ErrorBoundary> | ||
); | ||
}; | ||
|
||
export default ErrorBoundary; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.