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

Add ErrorHandler to site #639

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Add ErrorHandler to site #639

wants to merge 1 commit into from

Conversation

thomasdax98
Copy link
Member

Description

see vivid-planet/comet#2281

By switching to SSR instead of SSG, an error thrown in a block causes the entire page to crash (white screen). To avoid this, errors in the block are caught and handled in the ErrorHandler.

In development, the error is still thrown. In production, blocks with errors are simply hidden. A tool like Sentry should be configured where the error can be logged.

@thomasdax98 thomasdax98 added the recommended-change Change should be added to existing projects and be mentioned in the next migration guide label Dec 20, 2024
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@thomasdax98 thomasdax98 changed the title Add error handler Add ErrorHandler to site Dec 20, 2024
export function ErrorHandler({ children }: PropsWithChildren) {
function onError(error: Error, errorInfo: React.ErrorInfo) {
if (process.env.NODE_ENV === "development") {
console.error("Error caught by error handler", error, errorInfo.componentStack);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need this console log if we re-throw the error?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
recommended-change Change should be added to existing projects and be mentioned in the next migration guide
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants