@@ -21,7 +21,9 @@ describe('ExtraErrorData()', () => {
21
21
error . baz = 42 ;
22
22
error . foo = 'bar' ;
23
23
24
- const enhancedEvent = extraErrorData . enhanceEventWithErrorData ( event , error ) ;
24
+ const enhancedEvent = extraErrorData . enhanceEventWithErrorData ( event , {
25
+ originalException : error ,
26
+ } ) ;
25
27
26
28
expect ( enhancedEvent . extra ) . toEqual ( {
27
29
TypeError : {
@@ -35,7 +37,9 @@ describe('ExtraErrorData()', () => {
35
37
const error = new TypeError ( 'foo' ) as ExtendedError ;
36
38
error . cause = new SyntaxError ( 'bar' ) ;
37
39
38
- const enhancedEvent = extraErrorData . enhanceEventWithErrorData ( event , error ) ;
40
+ const enhancedEvent = extraErrorData . enhanceEventWithErrorData ( event , {
41
+ originalException : error ,
42
+ } ) ;
39
43
40
44
expect ( enhancedEvent . extra ) . toEqual ( {
41
45
TypeError : {
@@ -53,7 +57,9 @@ describe('ExtraErrorData()', () => {
53
57
const error = new TypeError ( 'foo' ) as ExtendedError ;
54
58
error . baz = 42 ;
55
59
56
- const enhancedEvent = extraErrorData . enhanceEventWithErrorData ( event , error ) ;
60
+ const enhancedEvent = extraErrorData . enhanceEventWithErrorData ( event , {
61
+ originalException : error ,
62
+ } ) ;
57
63
58
64
expect ( enhancedEvent . extra ) . toEqual ( {
59
65
TypeError : {
@@ -62,4 +68,28 @@ describe('ExtraErrorData()', () => {
62
68
foo : 42 ,
63
69
} ) ;
64
70
} ) ;
71
+
72
+ it ( 'should return event if originalException is not an Error object' , ( ) => {
73
+ const error = 'error message, not object' ;
74
+
75
+ const enhancedEvent = extraErrorData . enhanceEventWithErrorData ( event , {
76
+ originalException : error ,
77
+ } ) ;
78
+
79
+ expect ( enhancedEvent ) . toEqual ( event ) ;
80
+ } ) ;
81
+
82
+ it ( 'should return event if there is no SentryEventHint' , ( ) => {
83
+ const enhancedEvent = extraErrorData . enhanceEventWithErrorData ( event ) ;
84
+
85
+ expect ( enhancedEvent ) . toEqual ( event ) ;
86
+ } ) ;
87
+
88
+ it ( 'should return event if there is no originalException' , ( ) => {
89
+ const enhancedEvent = extraErrorData . enhanceEventWithErrorData ( event , {
90
+ notOriginalException : 'fooled you' ,
91
+ } ) ;
92
+
93
+ expect ( enhancedEvent ) . toEqual ( event ) ;
94
+ } ) ;
65
95
} ) ;
0 commit comments