@@ -6,7 +6,7 @@ function isHttpError(err: unknown): err is HttpError {
6
6
return typeof err === 'object' && err !== null && 'status' in err && 'body' in err ;
7
7
}
8
8
9
- function captureAndThrowError ( e : unknown ) : void {
9
+ function sendErrorToSentry ( e : unknown ) : unknown {
10
10
// In case we have a primitive, wrap it in the equivalent wrapper class (string -> String, etc.) so that we can
11
11
// store a seen flag on it.
12
12
const objectifiedErr = objectify ( e ) ;
@@ -15,7 +15,7 @@ function captureAndThrowError(e: unknown): void {
15
15
// If we detect a thrown error that is an instance of HttpError, we don't want to capture 4xx errors as they
16
16
// could be noisy.
17
17
if ( isHttpError ( objectifiedErr ) && objectifiedErr . status < 500 && objectifiedErr . status >= 400 ) {
18
- throw objectifiedErr ;
18
+ return objectifiedErr ;
19
19
}
20
20
21
21
captureException ( objectifiedErr , scope => {
@@ -33,7 +33,7 @@ function captureAndThrowError(e: unknown): void {
33
33
return scope ;
34
34
} ) ;
35
35
36
- throw objectifiedErr ;
36
+ return objectifiedErr ;
37
37
}
38
38
39
39
/**
@@ -49,12 +49,12 @@ export function wrapLoadWithSentry(origLoad: ServerLoad): ServerLoad {
49
49
try {
50
50
maybePromiseResult = wrappingTarget . apply ( thisArg , args ) ;
51
51
} catch ( e ) {
52
- captureAndThrowError ( e ) ;
52
+ throw sendErrorToSentry ( e ) ;
53
53
}
54
54
55
55
if ( isThenable ( maybePromiseResult ) ) {
56
56
Promise . resolve ( maybePromiseResult ) . then ( null , e => {
57
- captureAndThrowError ( e ) ;
57
+ sendErrorToSentry ( e ) ;
58
58
} ) ;
59
59
}
60
60
0 commit comments