Skip to content

Commit

Permalink
fix(remix): Check the error data before spreading. (#9664)
Browse files Browse the repository at this point in the history
  • Loading branch information
onurtemizkan authored Nov 27, 2023
1 parent 30eca53 commit 7249cf9
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion packages/remix/src/client/errors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ export function captureRemixErrorBoundaryError(error: unknown): string | undefin
const eventData = isRemixErrorResponse
? {
function: 'ErrorResponse',
...error.data,
...getErrorData(error),
}
: {
function: 'ReactError',
};

const actualError = isRemixErrorResponse ? getExceptionToCapture(error) : error;

eventId = captureException(actualError, {
mechanism: {
type: 'instrument',
Expand All @@ -42,10 +43,21 @@ export function captureRemixErrorBoundaryError(error: unknown): string | undefin
return eventId;
}

function getErrorData(error: ErrorResponse): object {
if (isString(error.data)) {
return {
error: error.data,
};
}

return error.data;
}

function getExceptionToCapture(error: ErrorResponse): string | ErrorResponse {
if (isString(error.data)) {
return error.data;
}

if (error.statusText) {
return error.statusText;
}
Expand Down

0 comments on commit 7249cf9

Please sign in to comment.