@@ -394,45 +394,43 @@ export abstract class BaseClient<B extends Backend, O extends Options> implement
394
394
395
395
let finalEvent : Event | null = prepared ;
396
396
397
- try {
398
- const isInternalException = hint && hint . data && ( hint . data as { [ key : string ] : any } ) . __sentry__ === true ;
399
- if ( isInternalException || ! beforeSend ) {
400
- this . _getBackend ( ) . sendEvent ( finalEvent ) ;
401
- resolve ( finalEvent ) ;
397
+ const isInternalException = hint && hint . data && ( hint . data as { [ key : string ] : any } ) . __sentry__ === true ;
398
+ if ( isInternalException || ! beforeSend ) {
399
+ this . _getBackend ( ) . sendEvent ( finalEvent ) ;
400
+ resolve ( finalEvent ) ;
401
+ return ;
402
+ }
403
+
404
+ const beforeSendResult = beforeSend ( prepared , hint ) ;
405
+ // tslint:disable-next-line:strict-type-predicates
406
+ if ( typeof beforeSendResult === 'undefined' ) {
407
+ logger . error ( '`beforeSend` method has to return `null` or a valid event.' ) ;
408
+ } else if ( isThenable ( beforeSendResult ) ) {
409
+ this . _handleAsyncBeforeSend ( beforeSendResult as PromiseLike < Event | null > , resolve , reject ) ;
410
+ } else {
411
+ finalEvent = beforeSendResult as Event | null ;
412
+
413
+ if ( finalEvent === null ) {
414
+ logger . log ( '`beforeSend` returned `null`, will not send event.' ) ;
415
+ resolve ( null ) ;
402
416
return ;
403
417
}
404
418
405
- const beforeSendResult = beforeSend ( prepared , hint ) ;
406
- // tslint:disable-next-line:strict-type-predicates
407
- if ( typeof beforeSendResult === 'undefined' ) {
408
- logger . error ( '`beforeSend` method has to return `null` or a valid event.' ) ;
409
- } else if ( isThenable ( beforeSendResult ) ) {
410
- this . _handleAsyncBeforeSend ( beforeSendResult as PromiseLike < Event | null > , resolve , reject ) ;
411
- } else {
412
- finalEvent = beforeSendResult as Event | null ;
413
-
414
- if ( finalEvent === null ) {
415
- logger . log ( '`beforeSend` returned `null`, will not send event.' ) ;
416
- resolve ( null ) ;
417
- return ;
418
- }
419
-
420
- // From here on we are really async
421
- this . _getBackend ( ) . sendEvent ( finalEvent ) ;
422
- resolve ( finalEvent ) ;
423
- }
424
- } catch ( exception ) {
425
- this . captureException ( exception , {
426
- data : {
427
- __sentry__ : true ,
428
- } ,
429
- originalException : exception as Error ,
430
- } ) ;
431
- reject ( '`beforeSend` threw an error, will not send event.' ) ;
419
+ // From here on we are really async
420
+ this . _getBackend ( ) . sendEvent ( finalEvent ) ;
421
+ resolve ( finalEvent ) ;
432
422
}
433
423
} )
434
- . then ( null , ( ) => {
435
- reject ( '`beforeSend` threw an error, will not send event.' ) ;
424
+ . then ( null , reason => {
425
+ this . captureException ( reason , {
426
+ data : {
427
+ __sentry__ : true ,
428
+ } ,
429
+ originalException : reason as Error ,
430
+ } ) ;
431
+ reject (
432
+ `Event processing pipeline threw an error, original event will not be sent. Details has been sent as a new event.\nReason: ${ reason } ` ,
433
+ ) ;
436
434
} ) ;
437
435
} ) ;
438
436
}
0 commit comments