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
@@ -89,6 +90,7 @@ export const withSentry = (origHandler: NextApiHandler): WrappedNextApiHandler =
89
90
captureException ( e ) ;
90
91
}
91
92
throw e ;
93
+ ( res as AugmentedNextApiResponse ) . __sentryCapturedError = e ;
92
94
}
93
95
} ) ;
94
96
@@ -100,8 +102,8 @@ type ResponseEndMethod = AugmentedNextApiResponse['end'];
100
102
type WrappedResponseEndMethod = AugmentedNextApiResponse [ 'end' ] ;
101
103
102
104
function wrapEndMethod ( origEnd : ResponseEndMethod ) : WrappedResponseEndMethod {
103
- const transaction = this . __sentryTransaction ;
104
105
return async function newEnd ( this : AugmentedNextApiResponse , ...args : unknown [ ] ) {
106
+ const { __sentryTransaction : transaction , __sentryCapturedError : capturedError } = this ;
105
107
106
108
if ( transaction ) {
107
109
transaction . setHttpStatus ( this . statusCode ) ;
You can’t perform that action at this time.
0 commit comments