|
1 | 1 | import { ExtendedError, WrappedFunction } from '@sentry/types'; |
2 | 2 |
|
3 | | -import { isError, isPrimitive, isSyntheticEvent, isEvent, isElement } from './is'; |
| 3 | +import { isElement, isError, isEvent, isPrimitive, isSyntheticEvent } from './is'; |
4 | 4 | import { Memo } from './memo'; |
5 | | -import { truncate } from './string'; |
6 | 5 | import { htmlTreeAsString } from './misc'; |
| 6 | +import { truncate } from './string'; |
7 | 7 |
|
8 | 8 | /** |
9 | 9 | * Wrap a given object method with a higher-order function |
@@ -104,12 +104,23 @@ function getWalkSource( |
104 | 104 | } = {}; |
105 | 105 |
|
106 | 106 | source.type = value.type; |
107 | | - source.target = isElement(value.target) |
108 | | - ? htmlTreeAsString(value.target) |
109 | | - : Object.prototype.toString.call(value.target); |
110 | | - source.currentTarget = isElement(value.currentTarget) |
111 | | - ? htmlTreeAsString(value.currentTarget) |
112 | | - : Object.prototype.toString.call(value.currentTarget); |
| 107 | + |
| 108 | + // Accessing event.target can throw (see getsentry/raven-js#838, #768) |
| 109 | + try { |
| 110 | + source.target = isElement(value.target) |
| 111 | + ? htmlTreeAsString(value.target) |
| 112 | + : Object.prototype.toString.call(value.target); |
| 113 | + } catch (_oO) { |
| 114 | + source.target = '<unknown>'; |
| 115 | + } |
| 116 | + |
| 117 | + try { |
| 118 | + source.currentTarget = isElement(value.currentTarget) |
| 119 | + ? htmlTreeAsString(value.currentTarget) |
| 120 | + : Object.prototype.toString.call(value.currentTarget); |
| 121 | + } catch (_oO) { |
| 122 | + source.currentTarget = '<unknown>'; |
| 123 | + } |
113 | 124 |
|
114 | 125 | // tslint:disable-next-line:strict-type-predicates |
115 | 126 | if (typeof CustomEvent !== 'undefined' && value instanceof CustomEvent) { |
|
0 commit comments