Skip to content

Commit

Permalink
fix(FEC-12275): add log when event exception happens (#666)
Browse files Browse the repository at this point in the history
  • Loading branch information
lianbenjamin authored Sep 22, 2022
1 parent c10c6df commit 9d467e1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/event/fake-event-target.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//@flow
import FakeEvent from './fake-event';
import {MultiMap} from '../utils/multi-map';
import getLogger from '../utils/logger';

/**
* A work-alike for EventTarget. Only DOM elements may be true EventTargets,
Expand All @@ -14,6 +15,7 @@ import {MultiMap} from '../utils/multi-map';
class FakeEventTarget {
_listeners: MultiMap<string, (event: FakeEvent) => boolean | void>;
dispatchTarget: FakeEventTarget;
logger: any;

constructor() {
/**
Expand All @@ -26,6 +28,7 @@ class FakeEventTarget {
* @type {FakeEventTarget}
*/
this.dispatchTarget = this;
this.logger = getLogger('FakeEventTarget');
}

/**
Expand Down Expand Up @@ -95,7 +98,7 @@ class FakeEventTarget {
// Exceptions during event handlers should not affect the caller,
// but should appear on the console as uncaught, according to MDN:
// http://goo.gl/N6Ff27
// TODO: add log
this.logger.error(`Error occurred when handling event: ${event.type}.`, exception);
}

if (event.stopped) {
Expand Down

0 comments on commit 9d467e1

Please sign in to comment.