Skip to content

Commit 594713e

Browse files
committed
fix(remix): Check the error data before spreading.
1 parent 4c75f85 commit 594713e

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

packages/remix/src/client/errors.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@ export function captureRemixErrorBoundaryError(error: unknown): string | undefin
2323
const eventData = isRemixErrorResponse
2424
? {
2525
function: 'ErrorResponse',
26-
...error.data,
26+
...getErrorData(error),
2727
}
2828
: {
2929
function: 'ReactError',
3030
};
3131

3232
const actualError = isRemixErrorResponse ? getExceptionToCapture(error) : error;
33+
3334
eventId = captureException(actualError, {
3435
mechanism: {
3536
type: 'instrument',
@@ -42,10 +43,21 @@ export function captureRemixErrorBoundaryError(error: unknown): string | undefin
4243
return eventId;
4344
}
4445

46+
function getErrorData(error: ErrorResponse): object {
47+
if (isString(error.data)) {
48+
return {
49+
error: error.data,
50+
};
51+
}
52+
53+
return error.data;
54+
}
55+
4556
function getExceptionToCapture(error: ErrorResponse): string | ErrorResponse {
4657
if (isString(error.data)) {
4758
return error.data;
4859
}
60+
4961
if (error.statusText) {
5062
return error.statusText;
5163
}

0 commit comments

Comments
 (0)