@@ -2,14 +2,12 @@ import { getCurrentHub } from '@sentry/core';
2
2
import { Event , Integration , Severity } from '@sentry/types' ;
3
3
import {
4
4
addExceptionMechanism ,
5
- addExceptionTypeValue ,
6
5
getGlobalObject ,
7
6
getLocationHref ,
8
7
isErrorEvent ,
9
8
isPrimitive ,
10
9
isString ,
11
10
logger ,
12
- truncate ,
13
11
} from '@sentry/utils' ;
14
12
15
13
import { eventFromUnknownInput } from '../eventbuilder' ;
@@ -98,13 +96,8 @@ export class GlobalHandlers implements Integration {
98
96
99
97
const event = isPrimitive ( error )
100
98
? self . _eventFromIncompleteOnError ( msg , url , line , column )
101
- : self . _enhanceEventWithInitialFrame ( eventFromUnknownInput ( error , undefined , 'error' ) , url , line , column ) ;
99
+ : self . _enhanceEventWithInitialFrame ( eventFromUnknownInput ( error , undefined ) , url , line , column ) ;
102
100
103
- const client = getCurrentHub ( ) . getClient ( ) ;
104
- const maxValueLength = ( client && client . getOptions ( ) . maxValueLength ) || 250 ;
105
- const fallbackValue = truncate ( `${ error || msg } ` , maxValueLength ) || '' ;
106
-
107
- addExceptionTypeValue ( event , fallbackValue , 'Error' ) ;
108
101
addExceptionMechanism ( event , {
109
102
handled : false ,
110
103
type : 'onerror' ,
@@ -153,13 +146,10 @@ export class GlobalHandlers implements Integration {
153
146
154
147
const event = isPrimitive ( error )
155
148
? self . _eventFromIncompleteRejection ( error )
156
- : eventFromUnknownInput ( error , undefined , 'promise' ) ;
149
+ : eventFromUnknownInput ( error , undefined , true ) ;
157
150
158
- const client = getCurrentHub ( ) . getClient ( ) ;
159
- const maxValueLength = ( client && client . getOptions ( ) . maxValueLength ) || 250 ;
160
- const fallbackValue = truncate ( `${ error } ` , maxValueLength ) || '' ;
151
+ event . level = Severity . Error ;
161
152
162
- addExceptionTypeValue ( event , fallbackValue , 'UnhandledRejection' ) ;
163
153
addExceptionMechanism ( event , {
164
154
handled : false ,
165
155
type : 'onunhandledrejection' ,
@@ -183,7 +173,7 @@ export class GlobalHandlers implements Integration {
183
173
* This function creates a stack from an old, error-less onerror handler.
184
174
*/
185
175
private _eventFromIncompleteOnError ( msg : any , url : any , line : any , column : any ) : Event {
186
- const ERROR_TYPES_RE = / ^ (?: [ U u ] n c a u g h t (?: e x c e p t i o n : ) ? ) ? (?: ( (?: E v a l | I n t e r n a l | R a n g e | R e f e r e n c e | S y n t a x | T y p e | U R I | ) E r r o r ) : ) ? ( .* ) $ / ;
176
+ const ERROR_TYPES_RE = / ^ (?: [ U u ] n c a u g h t (?: e x c e p t i o n : ) ? ) ? (?: ( (?: E v a l | I n t e r n a l | R a n g e | R e f e r e n c e | S y n t a x | T y p e | U R I | ) E r r o r ) : ) ? ( .* ) $ / i ;
187
177
188
178
// If 'message' is ErrorEvent, get real message from inside
189
179
let message = isErrorEvent ( msg ) ? msg . message : msg ;
@@ -201,8 +191,8 @@ export class GlobalHandlers implements Integration {
201
191
exception : {
202
192
values : [
203
193
{
194
+ type : name || 'Error' ,
204
195
value : message ,
205
- ...( name && { type : name } ) ,
206
196
} ,
207
197
] ,
208
198
} ,
@@ -216,8 +206,14 @@ export class GlobalHandlers implements Integration {
216
206
*/
217
207
private _eventFromIncompleteRejection ( error : any ) : Event {
218
208
return {
219
- level : Severity . Error ,
220
- message : `Non-Error promise rejection captured with value: ${ error } ` ,
209
+ exception : {
210
+ values : [
211
+ {
212
+ type : 'UnhandledRejection' ,
213
+ value : `Non-Error promise rejection captured with value: ${ error } ` ,
214
+ } ,
215
+ ] ,
216
+ } ,
221
217
} ;
222
218
}
223
219
0 commit comments