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