@@ -2,7 +2,7 @@ import { Backend, logger, Options, SentryError } from '@sentry/core';
2
2
import { SentryEvent , SentryResponse , Status } from '@sentry/types' ;
3
3
import { isDOMError , isDOMException , isError , isErrorEvent , isPlainObject } from '@sentry/utils/is' ;
4
4
import { supportsFetch } from '@sentry/utils/supports' ;
5
- import { eventFromStacktrace , getEventOptionsFromPlainObject , prepareFramesForEvent } from './parsers' ;
5
+ import { eventFromPlainObject , eventFromStacktrace , prepareFramesForEvent } from './parsers' ;
6
6
import { computeStackTrace } from './tracekit' ;
7
7
import { FetchTransport , XHRTransport } from './transports' ;
8
8
@@ -58,10 +58,13 @@ export class BrowserBackend implements Backend {
58
58
* @inheritDoc
59
59
*/
60
60
public async eventFromException ( exception : any , syntheticException : Error | null ) : Promise < SentryEvent > {
61
+ let event ;
62
+
61
63
if ( isErrorEvent ( exception as ErrorEvent ) && ( exception as ErrorEvent ) . error ) {
62
64
// If it is an ErrorEvent with `error` property, extract it to get actual Error
63
65
const ex = exception as ErrorEvent ;
64
66
exception = ex . error ; // tslint:disable-line:no-parameter-reassignment
67
+ event = eventFromStacktrace ( computeStackTrace ( exception as Error ) ) ;
65
68
} else if ( isDOMError ( exception as DOMError ) || isDOMException ( exception as DOMException ) ) {
66
69
// If it is a DOMError or DOMException (which are legacy APIs, but still supported in some browsers)
67
70
// then we just extract the name and message, as they don't provide anything else
@@ -71,16 +74,16 @@ export class BrowserBackend implements Backend {
71
74
const name = ex . name || ( isDOMError ( ex ) ? 'DOMError' : 'DOMException' ) ;
72
75
const message = ex . message ? `${ name } : ${ ex . message } ` : name ;
73
76
74
- return this . eventFromMessage ( message , syntheticException ) ;
77
+ event = await this . eventFromMessage ( message , syntheticException ) ;
75
78
} else if ( isError ( exception as Error ) ) {
76
79
// we have a real Error object, do nothing
80
+ event = eventFromStacktrace ( computeStackTrace ( exception as Error ) ) ;
77
81
} else if ( isPlainObject ( exception as { } ) ) {
78
82
// If it is plain Object, serialize it manually and extract options
79
83
// This will allow us to group events based on top-level keys
80
84
// which is much better than creating new group when any key/value change
81
85
const ex = exception as { } ;
82
- const options = getEventOptionsFromPlainObject ( ex ) ;
83
- exception = new Error ( options . message ) ; // tslint:disable-line:no-parameter-reassignment
86
+ event = eventFromPlainObject ( ex , syntheticException ) ;
84
87
} else {
85
88
// If none of previous checks were valid, then it means that
86
89
// it's not a DOMError/DOMException
@@ -89,11 +92,9 @@ export class BrowserBackend implements Backend {
89
92
// it's not an Error
90
93
// So bail out and capture it as a simple message:
91
94
const ex = exception as string ;
92
- return this . eventFromMessage ( ex , syntheticException ) ;
95
+ event = await this . eventFromMessage ( ex , syntheticException ) ;
93
96
}
94
97
95
- let event : SentryEvent = eventFromStacktrace ( computeStackTrace ( exception as Error ) ) ;
96
-
97
98
event = {
98
99
...event ,
99
100
exception : {
0 commit comments