@@ -33,7 +33,7 @@ class CustomError extends Error {
33
33
}
34
34
35
35
class ErrorLikeShapedClass implements Partial < Error > {
36
- constructor ( public message : string ) { }
36
+ constructor ( public name : string , public message : string ) { }
37
37
}
38
38
39
39
function createErrorEvent ( message : string , innerError : any ) : ErrorEvent {
@@ -118,8 +118,7 @@ describe('SentryErrorHandler', () => {
118
118
createErrorHandler ( ) . handleError ( errorLikeWithoutStack ) ;
119
119
120
120
expect ( captureExceptionSpy ) . toHaveBeenCalledTimes ( 1 ) ;
121
- // TODO: to be changed; see https://github.com/getsentry/sentry-javascript/issues/6332
122
- expect ( captureExceptionSpy ) . toHaveBeenCalledWith ( 'Handled unknown error' , expect . any ( Function ) ) ;
121
+ expect ( captureExceptionSpy ) . toHaveBeenCalledWith ( errorLikeWithoutStack , expect . any ( Function ) ) ;
123
122
} ) ;
124
123
125
124
it ( 'extracts an error-like object with a stack' , ( ) => {
@@ -132,8 +131,7 @@ describe('SentryErrorHandler', () => {
132
131
createErrorHandler ( ) . handleError ( errorLikeWithStack ) ;
133
132
134
133
expect ( captureExceptionSpy ) . toHaveBeenCalledTimes ( 1 ) ;
135
- // TODO: to be changed; see https://github.com/getsentry/sentry-javascript/issues/6332
136
- expect ( captureExceptionSpy ) . toHaveBeenCalledWith ( 'Handled unknown error' , expect . any ( Function ) ) ;
134
+ expect ( captureExceptionSpy ) . toHaveBeenCalledWith ( errorLikeWithStack , expect . any ( Function ) ) ;
137
135
} ) ;
138
136
139
137
it ( 'extracts an object that could look like an error but is not (does not have a message)' , ( ) => {
@@ -150,7 +148,6 @@ describe('SentryErrorHandler', () => {
150
148
151
149
it ( 'extracts an object that could look like an error but is not (does not have an explicit name)' , ( ) => {
152
150
const notErr : Partial < Error > = {
153
- // missing name; but actually is always there as part of the Object prototype
154
151
message : 'something failed.' ,
155
152
} ;
156
153
@@ -194,12 +191,12 @@ describe('SentryErrorHandler', () => {
194
191
} ) ;
195
192
196
193
it ( 'extracts an instance of class not extending Error but that has an error-like shape' , ( ) => {
197
- const err = new ErrorLikeShapedClass ( 'something happened' ) ;
194
+ const err = new ErrorLikeShapedClass ( 'sentry-error' , ' something happened') ;
198
195
199
196
createErrorHandler ( ) . handleError ( err ) ;
200
197
201
198
expect ( captureExceptionSpy ) . toHaveBeenCalledTimes ( 1 ) ;
202
- expect ( captureExceptionSpy ) . toHaveBeenCalledWith ( 'Handled unknown error' , expect . any ( Function ) ) ;
199
+ expect ( captureExceptionSpy ) . toHaveBeenCalledWith ( err , expect . any ( Function ) ) ;
203
200
} ) ;
204
201
205
202
it ( 'extracts an instance of a class that does not extend Error and does not have an error-like shape' , ( ) => {
@@ -304,11 +301,7 @@ describe('SentryErrorHandler', () => {
304
301
createErrorHandler ( ) . handleError ( err ) ;
305
302
306
303
expect ( captureExceptionSpy ) . toHaveBeenCalledTimes ( 1 ) ;
307
- // TODO: to be changed; see https://github.com/getsentry/sentry-javascript/issues/6332
308
- expect ( captureExceptionSpy ) . toHaveBeenCalledWith (
309
- 'Http failure response for (unknown url): undefined undefined' ,
310
- expect . any ( Function ) ,
311
- ) ;
304
+ expect ( captureExceptionSpy ) . toHaveBeenCalledWith ( errorLikeWithoutStack , expect . any ( Function ) ) ;
312
305
} ) ;
313
306
314
307
it ( 'extracts an `HttpErrorResponse` with error-like object with a stack' , ( ) => {
@@ -322,11 +315,7 @@ describe('SentryErrorHandler', () => {
322
315
createErrorHandler ( ) . handleError ( err ) ;
323
316
324
317
expect ( captureExceptionSpy ) . toHaveBeenCalledTimes ( 1 ) ;
325
- // TODO: to be changed; see https://github.com/getsentry/sentry-javascript/issues/6332
326
- expect ( captureExceptionSpy ) . toHaveBeenCalledWith (
327
- 'Http failure response for (unknown url): undefined undefined' ,
328
- expect . any ( Function ) ,
329
- ) ;
318
+ expect ( captureExceptionSpy ) . toHaveBeenCalledWith ( errorLikeWithStack , expect . any ( Function ) ) ;
330
319
} ) ;
331
320
332
321
it ( 'extracts an `HttpErrorResponse` with an object that could look like an error but is not (does not have a message)' , ( ) => {
@@ -347,7 +336,6 @@ describe('SentryErrorHandler', () => {
347
336
348
337
it ( 'extracts an `HttpErrorResponse` with an object that could look like an error but is not (does not have an explicit name)' , ( ) => {
349
338
const notErr : Partial < Error > = {
350
- // missing name; but actually is always there as part of the Object prototype
351
339
message : 'something failed.' ,
352
340
} ;
353
341
const err = new HttpErrorResponse ( { error : notErr } ) ;
@@ -453,16 +441,13 @@ describe('SentryErrorHandler', () => {
453
441
} ) ;
454
442
455
443
it ( 'extracts an `HttpErrorResponse` with an instance of class not extending Error but that has an error-like shape' , ( ) => {
456
- const innerErr = new ErrorLikeShapedClass ( 'something happened' ) ;
444
+ const innerErr = new ErrorLikeShapedClass ( 'sentry-error' , ' something happened') ;
457
445
const err = new HttpErrorResponse ( { error : innerErr } ) ;
458
446
459
447
createErrorHandler ( ) . handleError ( err ) ;
460
448
461
449
expect ( captureExceptionSpy ) . toHaveBeenCalledTimes ( 1 ) ;
462
- expect ( captureExceptionSpy ) . toHaveBeenCalledWith (
463
- 'Http failure response for (unknown url): undefined undefined' ,
464
- expect . any ( Function ) ,
465
- ) ;
450
+ expect ( captureExceptionSpy ) . toHaveBeenCalledWith ( innerErr , expect . any ( Function ) ) ;
466
451
} ) ;
467
452
468
453
it ( 'extracts an `HttpErrorResponse` with an instance of a class that does not extend Error and does not have an error-like shape' , ( ) => {
0 commit comments