File tree Expand file tree Collapse file tree 1 file changed +3
-1
lines changed
packages/nextjs/src/utils Expand file tree Collapse file tree 1 file changed +3
-1
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ type WrappedNextApiHandler = NextApiHandler;
12
12
13
13
export type AugmentedNextApiResponse = NextApiResponse & {
14
14
__sentryTransaction ?: Transaction ;
15
+ __sentryCapturedError ?: unknown ;
15
16
} ;
16
17
17
18
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
@@ -88,6 +89,7 @@ export const withSentry = (origHandler: NextApiHandler): WrappedNextApiHandler =
88
89
captureException ( e ) ;
89
90
}
90
91
throw e ;
92
+ ( res as AugmentedNextApiResponse ) . __sentryCapturedError = e ;
91
93
}
92
94
} ) ;
93
95
@@ -99,8 +101,8 @@ type ResponseEndMethod = AugmentedNextApiResponse['end'];
99
101
type WrappedResponseEndMethod = AugmentedNextApiResponse [ 'end' ] ;
100
102
101
103
function wrapEndMethod ( origEnd : ResponseEndMethod ) : WrappedResponseEndMethod {
102
- const transaction = this . __sentryTransaction ;
103
104
return async function newEnd ( this : AugmentedNextApiResponse , ...args : unknown [ ] ) {
105
+ const { __sentryTransaction : transaction , __sentryCapturedError : capturedError } = this ;
104
106
105
107
if ( transaction ) {
106
108
transaction . setHttpStatus ( this . statusCode ) ;
You can’t perform that action at this time.
0 commit comments