File tree Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -18,10 +18,18 @@ export class ExtraErrorData implements Integration {
1818 */
1919 public name : string = ExtraErrorData . id ;
2020
21+ /** JSDoc */
22+ private readonly _options : ExtraErrorDataOptions ;
23+
2124 /**
2225 * @inheritDoc
2326 */
24- public constructor ( private readonly _options : ExtraErrorDataOptions = { depth : 3 } ) { }
27+ public constructor ( options ?: ExtraErrorDataOptions ) {
28+ this . _options = {
29+ depth : 3 ,
30+ ...options ,
31+ } ;
32+ }
2533
2634 /**
2735 * @inheritDoc
Original file line number Diff line number Diff line change @@ -42,6 +42,31 @@ describe('ExtraErrorData()', () => {
4242 } ) ;
4343 } ) ;
4444
45+ it ( 'should stringify up to 3 nested levels by default' , ( ) => {
46+ const error = new TypeError ( 'foo' ) as ExtendedError ;
47+ error [ '1' ] = {
48+ 2 : {
49+ 3 : {
50+ 4 : 'foo' ,
51+ } ,
52+ } ,
53+ } ;
54+
55+ const enhancedEvent = extraErrorData . enhanceEventWithErrorData ( event , {
56+ originalException : error ,
57+ } ) ;
58+
59+ expect ( enhancedEvent . contexts ) . toEqual ( {
60+ TypeError : {
61+ 1 : {
62+ 2 : {
63+ 3 : '[Object]' ,
64+ } ,
65+ } ,
66+ } ,
67+ } ) ;
68+ } ) ;
69+
4570 it ( 'should not remove previous data existing in extra field' , ( ) => {
4671 event = {
4772 // @ts -ignore Allow contexts on event
You can’t perform that action at this time.
0 commit comments