@@ -87,9 +87,9 @@ async function extractResponseError(response: Response): Promise<unknown> {
8787 *
8888 * Should be used in `entry.server` like:
8989 *
90- * export const handleError = Sentry.wrapRemixHandleError
90+ * export const handleError = Sentry.sentryHandleError
9191 */
92- export function wrapRemixHandleError ( err : unknown , { request } : DataFunctionArgs ) : void {
92+ export function sentryHandleError ( err : unknown , { request } : DataFunctionArgs ) : void {
9393 // We are skipping thrown responses here as they are handled by
9494 // `captureRemixServerException` at loader / action level
9595 // We don't want to capture them twice.
@@ -105,6 +105,26 @@ export function wrapRemixHandleError(err: unknown, { request }: DataFunctionArgs
105105 } ) ;
106106}
107107
108+ // To be deprecated in favor of `sentryHandleError`
109+ export const wrapRemixHandleError = sentryHandleError ;
110+
111+ /**
112+ * Sentry wrapper for Remix's `handleError` function.
113+ * Remix Docs: https://remix.run/docs/en/main/file-conventions/entry.server#handleerror
114+ */
115+ export function wrapHandleErrorWithSentry (
116+ origHandleError : ( err : unknown , args : unknown ) => void ,
117+ ) : ( err : unknown , args : unknown ) => void {
118+ return function ( this : unknown , err : unknown , args : unknown ) : void {
119+ // This is expected to be void but just in case it changes in the future.
120+ const res = origHandleError . call ( this , err , args ) ;
121+
122+ sentryHandleError ( err , args as DataFunctionArgs ) ;
123+
124+ return res ;
125+ } ;
126+ }
127+
108128/**
109129 * Captures an exception happened in the Remix server.
110130 *
0 commit comments