Skip to content

Commit f7693b3

Browse files
author
Brian Vaughn
committed
Merge branch 'interaction-tracking' into interaction-tracking-profiler-integration
2 parents a8611b1 + d5ebc31 commit f7693b3

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

packages/interaction-tracking/src/InteractionTracking.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ export function track(
157157
// Update before calling callback in case it schedules follow-up work.
158158
interaction.__count = 1;
159159

160-
let caughtError = null;
160+
let caughtError;
161+
let didCatch = false;
161162
let returnValue;
162163
const subscriber = ((subscriberRef: any): SubscriberRef).current;
163164

@@ -166,13 +167,15 @@ export function track(
166167
subscriber.onInteractionTracked(interaction);
167168
subscriber.onWorkStarted(interactions, threadID);
168169
} catch (error) {
170+
didCatch = true;
169171
caughtError = caughtError || error;
170172
}
171173
}
172174

173175
try {
174176
returnValue = callback();
175177
} catch (error) {
178+
didCatch = true;
176179
caughtError = caughtError || error;
177180
}
178181

@@ -182,6 +185,7 @@ export function track(
182185
try {
183186
subscriber.onWorkStopped(interactions, threadID);
184187
} catch (error) {
188+
didCatch = true;
185189
caughtError = caughtError || error;
186190
}
187191
}
@@ -194,11 +198,12 @@ export function track(
194198
try {
195199
subscriber.onInteractionScheduledWorkCompleted(interaction);
196200
} catch (error) {
201+
didCatch = true;
197202
caughtError = caughtError || error;
198203
}
199204
}
200205

201-
if (caughtError !== null) {
206+
if (didCatch) {
202207
throw caughtError;
203208
} else {
204209
return returnValue;
@@ -249,20 +254,23 @@ export function wrap(
249254
const subscriber = ((subscriberRef: any): SubscriberRef).current;
250255

251256
try {
252-
let caughtError = null;
257+
let caughtError;
258+
let didCatch = false;
253259
let returnValue;
254260

255261
try {
256262
if (subscriber !== null) {
257263
subscriber.onWorkStarted(wrappedInteractions, threadID);
258264
}
259265
} catch (error) {
266+
didCatch = true;
260267
caughtError = caughtError || error;
261268
}
262269

263270
try {
264271
returnValue = callback(...args);
265272
} catch (error) {
273+
didCatch = true;
266274
caughtError = caughtError || error;
267275
}
268276

@@ -273,10 +281,11 @@ export function wrap(
273281
subscriber.onWorkStopped(wrappedInteractions, threadID);
274282
}
275283
} catch (error) {
284+
didCatch = true;
276285
caughtError = caughtError || error;
277286
}
278287

279-
if (caughtError !== null) {
288+
if (didCatch) {
280289
throw caughtError;
281290
} else {
282291
return returnValue;

0 commit comments

Comments
 (0)