MCPcopy Index your code
hub / github.com/getsentry/sentry-javascript / checkOrSetAlreadyCaught

Function checkOrSetAlreadyCaught

packages/core/src/utils/misc.ts:214–228  ·  view source on GitHub ↗
(exception: unknown)

Source from the content-addressed store, hash-verified

212 * @returns `true` if the exception has already been captured, `false` if not (with the side effect of marking it seen)
213 */
214export function checkOrSetAlreadyCaught(exception: unknown): boolean {
215 if (isAlreadyCaptured(exception)) {
216 return true;
217 }
218
219 try {
220 // set it this way rather than by assignment so that it's not ennumerable and therefore isn't recorded by the
221 // `ExtraErrorData` integration
222 addNonEnumerableProperty(exception as { [key: string]: unknown }, '__sentry_captured__', true);
223 } catch {
224 // `exception` is a primitive, so we can't mark it seen
225 }
226
227 return false;
228}
229
230/**
231 * Checks whether we've already captured the given exception (note: not an identical exception - the very object).

Callers 3

misc.test.tsFile · 0.90
captureExceptionFunction · 0.90
captureEventFunction · 0.90

Calls 2

addNonEnumerablePropertyFunction · 0.90
isAlreadyCapturedFunction · 0.85

Tested by

no test coverage detected