Skip to content

Commit 50d139c

Browse files
committed
misc: Update comments and remove redundent branch in extractExceptionKeysForMessage
1 parent 43309e5 commit 50d139c

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

packages/browser/src/eventbuilder.ts

+8-5
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,14 @@ export function eventFromUnknownInput(exception: unknown, syntheticException?: E
5454
return event;
5555
}
5656

57-
// If none of previous checks were valid, then it means that
58-
// it's not a DOMError/DOMException
59-
// it's not a plain Object
60-
// it's not a valid ErrorEvent (one with an error property)
61-
// it's not an Error
57+
// If none of previous checks were valid, then it means that it's not:
58+
// - an instance of DOMError
59+
// - an instance of DOMException
60+
// - an instance of Event
61+
// - an instance of Error
62+
// - a valid ErrorEvent (one with an error property)
63+
// - a plain Object
64+
//
6265
// So bail out and capture it as a simple message:
6366
event = eventFromString(exception as string, syntheticException);
6467
addExceptionTypeValue(event, `${exception}`, undefined);

packages/utils/src/object.ts

+5-11
Original file line numberDiff line numberDiff line change
@@ -316,20 +316,14 @@ export function normalize(input: any, depth?: number): any {
316316
}
317317
}
318318

319-
/** Merges provided array of keys into */
319+
/**
320+
* Given any captured exception, extract its keys and create a sorted
321+
* and truncated list that will be used inside the event message.
322+
* eg. `Non-error exception captured with keys: foo, bar, baz`
323+
*/
320324
export function extractExceptionKeysForMessage(exception: any, maxLength: number = 40): string {
321325
// tslint:disable:strict-type-predicates
322326
const keys = Object.keys(getWalkSource(exception));
323-
324-
// TODO: Extract keys for a specific types here
325-
if (typeof Event !== 'undefined' && exception instanceof Event) {
326-
// keys = [];
327-
} else if (typeof CustomEvent !== 'undefined' && exception instanceof CustomEvent) {
328-
// keys = [];
329-
} else if (typeof ErrorEvent !== 'undefined' && exception instanceof ErrorEvent) {
330-
// keys = [];
331-
}
332-
333327
keys.sort();
334328

335329
if (!keys.length) {

0 commit comments

Comments
 (0)