Error Boundary demos

These pages will demonstrate failing code in production and how you can use the library @dnb/error-boundary to catch them.

ErrorBoundary

The component is used to catch errors occuring in a small part of your code, such as in a component.

useErrorHandler

ErrorBoundary catches errors in lifecycle methods, in render and in the constructur of a React child component. It does not by default catch errors in event handlers and async code. You can handle those errors with the hook useErrorHandler(), which will throw an error to the closest ErrorBoundary wrapping the component.

GlobalErrorBoundary

The component wraps your app by default from @dnb/root-app and will catch all render errors occuring which you haven't wrapped with <ErrorBoundary>.

In development: Remember to click away the error handler first displayed by Gatsby to see what it will look like in production.