File tree 1 file changed +8
-0
lines changed
packages/nextjs/src/utils
1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -77,20 +77,26 @@ export const withSentry = (origHandler: NextApiHandler): WrappedNextApiHandler =
77
77
}
78
78
79
79
try {
80
+ console . log ( 'about to call handler' ) ;
80
81
return await origHandler ( req , res ) ; // Call original handler
81
82
} catch ( e ) {
83
+ console . log ( 'in catch right after calling handler' ) ;
84
+
82
85
console . error ( e ) ;
83
86
84
87
if ( currentScope ) {
85
88
currentScope . addEventProcessor ( event => {
89
+ console . log ( 'in event processor adding exception mechanism' ) ;
86
90
addExceptionMechanism ( event , {
87
91
mechanism : 'withSentry' ,
88
92
handled : false ,
89
93
} ) ;
90
94
return event ;
91
95
} ) ;
96
+ console . log ( 'about to capture the error' ) ;
92
97
captureException ( e ) ;
93
98
}
99
+ console . log ( 'about to call res.end() with the captured error' ) ;
94
100
( res as AugmentedNextApiResponse ) . __sentryCapturedError = e ;
95
101
res . end ( ) ;
96
102
}
@@ -104,7 +110,9 @@ type ResponseEndMethod = AugmentedNextApiResponse['end'];
104
110
type WrappedResponseEndMethod = AugmentedNextApiResponse [ 'end' ] ;
105
111
106
112
function wrapEndMethod ( origEnd : ResponseEndMethod ) : WrappedResponseEndMethod {
113
+ console . log ( 'wrapping end method' ) ;
107
114
return async function newEnd ( this : AugmentedNextApiResponse , ...args : unknown [ ] ) {
115
+ console . log ( 'in newEnd' ) ;
108
116
const { __sentryTransaction : transaction , __sentryCapturedError : capturedError } = this ;
109
117
110
118
if ( transaction ) {
You can’t perform that action at this time.
0 commit comments