You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adds support for new error handling utilities of Remix v2.
([ErrorBoundary](https://remix.run/docs/en/main/route/error-boundary-v2),
[handleError](https://github.com/remix-run/remix/releases/tag/remix%401.17.0))
## `ErrorBoundary` v2
Remix's `ErrorBoundary` captures all client / server / SSR errors and
shows a customizable error page.
In v1, to capture client-side errors we were wrapping the whole Remix
application with `@sentry/react`s `ErrorBoundary` which caused
inconsistencies in error pages. (See:
#5762)
v2 implementation does not wrap user's application with
`@sentry/react`'s ErrorBoundary, instead it exports a capturing utility
to be used inside the Remix application's `ErrorBoundary` function.
Can be used like:
```typescript
import { captureRemixErrorBoundaryError } from '@sentry/remix';
export const ErrorBoundary: V2_ErrorBoundaryComponent = () => {
const error = useRouteError();
captureRemixErrorBoundaryError(error);
return <div> ... </div>;
};
```
It also requires `v2_errorBoundary` [future
flag](https://remix.run/docs/en/1.18.0/pages/api-development-strategy#current-future-flags)
to be enabled.
## `handleError`
For server-side errors apart from 'Error Responses' (thrown responses
are handled in `ErrorBoundary`), this implementation exports another
utility to be used in `handleError` function. The errors we capture in
`handleError` also appear on `ErrorBoundary` functions but stacktraces
are not available. So, we skip those errors in
`captureRemixErrorBoundaryError` function.
`handleError` can be instrumented as below:
```typescript
export function handleError(error: unknown, { request }: DataFunctionArgs): void {
if (error instanceof Error) {
Sentry.captureRemixServerException(error, 'remix.server', request);
} else {
// Optionally
Sentry.captureException(error);
}
```
Copy file name to clipboardExpand all lines: packages/remix/src/utils/vendor/response.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@
6
6
//
7
7
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
0 commit comments