@@ -17,11 +17,13 @@ import { eventFromError, eventFromPlainObject, parseStackFrames } from './parser
17
17
* Creates an {@link Event} from all inputs to `captureException` and non-primitive inputs to `captureMessage`.
18
18
* @hidden
19
19
*/
20
- export function eventFromException ( options : Options , exception : unknown , hint ?: EventHint ) : PromiseLike < Event > {
20
+ export function eventFromException (
21
+ exception : unknown ,
22
+ hint ?: EventHint ,
23
+ attachStacktrace ?: Options [ 'attachStacktrace' ] ,
24
+ ) : PromiseLike < Event > {
21
25
const syntheticException = ( hint && hint . syntheticException ) || undefined ;
22
- const event = eventFromUnknownInput ( exception , syntheticException , {
23
- attachStacktrace : options . attachStacktrace ,
24
- } ) ;
26
+ const event = eventFromUnknownInput ( exception , syntheticException , attachStacktrace ) ;
25
27
addExceptionMechanism ( event ) ; // defaults to { type: 'generic', handled: true }
26
28
event . level = Severity . Error ;
27
29
if ( hint && hint . event_id ) {
@@ -35,15 +37,13 @@ export function eventFromException(options: Options, exception: unknown, hint?:
35
37
* @hidden
36
38
*/
37
39
export function eventFromMessage (
38
- options : Options ,
39
40
message : string ,
40
41
level : Severity = Severity . Info ,
41
42
hint ?: EventHint ,
43
+ attachStacktrace ?: Options [ 'attachStacktrace' ] ,
42
44
) : PromiseLike < Event > {
43
45
const syntheticException = ( hint && hint . syntheticException ) || undefined ;
44
- const event = eventFromString ( message , syntheticException , {
45
- attachStacktrace : options . attachStacktrace ,
46
- } ) ;
46
+ const event = eventFromString ( message , syntheticException , attachStacktrace ) ;
47
47
event . level = level ;
48
48
if ( hint && hint . event_id ) {
49
49
event . event_id = hint . event_id ;
@@ -57,10 +57,8 @@ export function eventFromMessage(
57
57
export function eventFromUnknownInput (
58
58
exception : unknown ,
59
59
syntheticException ?: Error ,
60
- options : {
61
- isRejection ?: boolean ;
62
- attachStacktrace ?: boolean ;
63
- } = { } ,
60
+ attachStacktrace ?: Options [ 'attachStacktrace' ] ,
61
+ isUnhandledRejection ?: boolean ,
64
62
) : Event {
65
63
let event : Event ;
66
64
@@ -85,7 +83,7 @@ export function eventFromUnknownInput(
85
83
} else {
86
84
const name = domException . name || ( isDOMError ( domException ) ? 'DOMError' : 'DOMException' ) ;
87
85
const message = domException . message ? `${ name } : ${ domException . message } ` : name ;
88
- event = eventFromString ( message , syntheticException , options ) ;
86
+ event = eventFromString ( message , syntheticException , attachStacktrace ) ;
89
87
addExceptionTypeValue ( event , message ) ;
90
88
}
91
89
if ( 'code' in domException ) {
@@ -103,7 +101,7 @@ export function eventFromUnknownInput(
103
101
// it manually. This will allow us to group events based on top-level keys which is much better than creating a new
104
102
// group on any key/value change.
105
103
const objectException = exception as Record < string , unknown > ;
106
- event = eventFromPlainObject ( objectException , syntheticException , options . isRejection ) ;
104
+ event = eventFromPlainObject ( objectException , syntheticException , isUnhandledRejection ) ;
107
105
addExceptionMechanism ( event , {
108
106
synthetic : true ,
109
107
} ) ;
@@ -119,7 +117,7 @@ export function eventFromUnknownInput(
119
117
// - a plain Object
120
118
//
121
119
// So bail out and capture it as a simple message:
122
- event = eventFromString ( exception as string , syntheticException , options ) ;
120
+ event = eventFromString ( exception as string , syntheticException , attachStacktrace ) ;
123
121
addExceptionTypeValue ( event , `${ exception } ` , undefined ) ;
124
122
addExceptionMechanism ( event , {
125
123
synthetic : true ,
@@ -134,15 +132,13 @@ export function eventFromUnknownInput(
134
132
export function eventFromString (
135
133
input : string ,
136
134
syntheticException ?: Error ,
137
- options : {
138
- attachStacktrace ?: boolean ;
139
- } = { } ,
135
+ attachStacktrace ?: Options [ 'attachStacktrace' ] ,
140
136
) : Event {
141
137
const event : Event = {
142
138
message : input ,
143
139
} ;
144
140
145
- if ( options . attachStacktrace && syntheticException ) {
141
+ if ( attachStacktrace && syntheticException ) {
146
142
const frames = parseStackFrames ( syntheticException ) ;
147
143
if ( frames . length ) {
148
144
event . stacktrace = { frames } ;
0 commit comments