@@ -33,7 +33,7 @@ class CustomError extends Error {
3333}
3434
3535class ErrorLikeShapedClass implements Partial < Error > {
36- constructor ( public message : string ) { }
36+ constructor ( public name : string , public message : string ) { }
3737}
3838
3939function createErrorEvent ( message : string , innerError : any ) : ErrorEvent {
@@ -118,8 +118,7 @@ describe('SentryErrorHandler', () => {
118118 createErrorHandler ( ) . handleError ( errorLikeWithoutStack ) ;
119119
120120 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 ) ) ;
123122 } ) ;
124123
125124 it ( 'extracts an error-like object with a stack' , ( ) => {
@@ -132,8 +131,7 @@ describe('SentryErrorHandler', () => {
132131 createErrorHandler ( ) . handleError ( errorLikeWithStack ) ;
133132
134133 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 ) ) ;
137135 } ) ;
138136
139137 it ( 'extracts an object that could look like an error but is not (does not have a message)' , ( ) => {
@@ -150,7 +148,6 @@ describe('SentryErrorHandler', () => {
150148
151149 it ( 'extracts an object that could look like an error but is not (does not have an explicit name)' , ( ) => {
152150 const notErr : Partial < Error > = {
153- // missing name; but actually is always there as part of the Object prototype
154151 message : 'something failed.' ,
155152 } ;
156153
@@ -194,12 +191,12 @@ describe('SentryErrorHandler', () => {
194191 } ) ;
195192
196193 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') ;
198195
199196 createErrorHandler ( ) . handleError ( err ) ;
200197
201198 expect ( captureExceptionSpy ) . toHaveBeenCalledTimes ( 1 ) ;
202- expect ( captureExceptionSpy ) . toHaveBeenCalledWith ( 'Handled unknown error' , expect . any ( Function ) ) ;
199+ expect ( captureExceptionSpy ) . toHaveBeenCalledWith ( err , expect . any ( Function ) ) ;
203200 } ) ;
204201
205202 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', () => {
304301 createErrorHandler ( ) . handleError ( err ) ;
305302
306303 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 ) ) ;
312305 } ) ;
313306
314307 it ( 'extracts an `HttpErrorResponse` with error-like object with a stack' , ( ) => {
@@ -322,11 +315,7 @@ describe('SentryErrorHandler', () => {
322315 createErrorHandler ( ) . handleError ( err ) ;
323316
324317 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 ) ) ;
330319 } ) ;
331320
332321 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', () => {
347336
348337 it ( 'extracts an `HttpErrorResponse` with an object that could look like an error but is not (does not have an explicit name)' , ( ) => {
349338 const notErr : Partial < Error > = {
350- // missing name; but actually is always there as part of the Object prototype
351339 message : 'something failed.' ,
352340 } ;
353341 const err = new HttpErrorResponse ( { error : notErr } ) ;
@@ -453,16 +441,13 @@ describe('SentryErrorHandler', () => {
453441 } ) ;
454442
455443 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') ;
457445 const err = new HttpErrorResponse ( { error : innerErr } ) ;
458446
459447 createErrorHandler ( ) . handleError ( err ) ;
460448
461449 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 ) ) ;
466451 } ) ;
467452
468453 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