Skip to content

Commit c6344b1

Browse files
committed
add lots of logging to withSentry
1 parent 5cdef07 commit c6344b1

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

packages/nextjs/src/utils/withSentry.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,22 @@ export const withSentry = (handler: NextApiHandler): WrappedNextApiHandler => {
7474
}
7575

7676
try {
77+
console.log('about to call handler');
7778
return await handler(req, res); // Call original handler
7879
} catch (e) {
80+
console.log('in catch right after calling handler');
7981
if (currentScope) {
8082
currentScope.addEventProcessor(event => {
83+
console.log('in event processor adding exception mechanism');
8184
addExceptionMechanism(event, {
8285
handled: false,
8386
});
8487
return event;
8588
});
89+
console.log('about to capture the error');
8690
captureException(e);
8791
}
92+
console.log('about to rethrow error');
8893
throw e;
8994
}
9095
});
@@ -97,7 +102,9 @@ type ResponseEndMethod = AugmentedResponse['end'];
97102
type WrappedResponseEndMethod = AugmentedResponse['end'];
98103

99104
function wrapEndMethod(origEnd: ResponseEndMethod): WrappedResponseEndMethod {
105+
console.log('wrapping end method');
100106
return async function newEnd(this: AugmentedResponse, ...args: unknown[]) {
107+
console.log('in newEnd');
101108
const transaction = this.__sentryTransaction;
102109

103110
if (transaction) {
@@ -124,6 +131,7 @@ function wrapEndMethod(origEnd: ResponseEndMethod): WrappedResponseEndMethod {
124131
logger.log(`Error while flushing events:\n${e}`);
125132
}
126133

134+
console.log('about to call origEnd');
127135
return origEnd.call(this, ...args);
128136
};
129137
}

0 commit comments

Comments
 (0)