Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion packages/remix/src/utils/instrumentServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export async function captureRemixServerException(err: unknown, name: string, re
// Skip capturing if the request is aborted as Remix docs suggest
// Ref: https://remix.run/docs/en/main/file-conventions/entry.server#handleerror
if (request.signal.aborted) {
__DEBUG_BUILD__ && logger.warn('Skipping capture of aborted request');
DEBUG_BUILD && logger.warn('Skipping capture of aborted request');
return;
}

Expand Down