Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion packages/integrations/src/extraerrordata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,18 @@ export class ExtraErrorData implements Integration {
*/
public name: string = ExtraErrorData.id;

/** JSDoc */
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure what purpose does this have but I saw it the debug.ts's code

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s to get around writing doc strings. We can leave it like this.

private readonly _options: ExtraErrorDataOptions;

/**
* @inheritDoc
*/
public constructor(private readonly _options: ExtraErrorDataOptions = { depth: 3 }) {}
public constructor(options?: ExtraErrorDataOptions) {
this._options = {
depth: 3,
...options,
};
}

/**
* @inheritDoc
Expand Down
25 changes: 25 additions & 0 deletions packages/integrations/test/extraerrordata.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,31 @@ describe('ExtraErrorData()', () => {
});
});

it('should stringify up to 3 nested levels by default', () => {
const error = new TypeError('foo') as ExtendedError;
error['1'] = {
2: {
3: {
4: 'foo',
},
},
};

const enhancedEvent = extraErrorData.enhanceEventWithErrorData(event, {
originalException: error,
});

expect(enhancedEvent.contexts).toEqual({
TypeError: {
1: {
2: {
3: '[Object]',
},
},
},
});
});

it('should not remove previous data existing in extra field', () => {
event = {
// @ts-ignore Allow contexts on event
Expand Down