Skip to content

Commit

Permalink
define option types better
Browse files Browse the repository at this point in the history
  • Loading branch information
mydea committed Jul 19, 2024
1 parent aecfb71 commit 3c462a8
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions packages/node/src/integrations/tracing/express.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,18 @@ type ExpressMiddleware = (
next: (error: MiddlewareError) => void,
) => void;

/**
* An Express-compatible error handler.
*/
export function expressErrorHandler(options?: {
interface ExpressHandlerOptions {
/**
* Callback method deciding whether error should be captured and sent to Sentry
* @param error Captured middleware error
*/
shouldHandleError?(this: void, error: MiddlewareError): boolean;
}): ExpressMiddleware {
}

/**
* An Express-compatible error handler.
*/
export function expressErrorHandler(options?: ExpressHandlerOptions): ExpressMiddleware {
return function sentryErrorMiddleware(
error: MiddlewareError,
_req: http.IncomingMessage,
Expand Down Expand Up @@ -137,7 +139,7 @@ export function expressErrorHandler(options?: {
*/
export function setupExpressErrorHandler(
app: { use: (middleware: ExpressMiddleware) => unknown },
options?: Parameters<typeof expressErrorHandler>[0],
options?: ExpressHandlerOptions,
): void {
app.use(expressErrorHandler(options));
ensureIsWrapped(app.use, 'express');
Expand Down

0 comments on commit 3c462a8

Please sign in to comment.