catch errors in logs listener
Summary: If one logListener was to throw an error, the others wouldn't receive the logs anymore. Reviewed By: jknoxville Differential Revision: D13881128 fbshipit-source-id: a653ba9279380c25bbc7ae2fd0c63de0884aa441
This commit is contained in:
committed by
Facebook Github Bot
parent
f12226ac00
commit
599b069943
@@ -98,7 +98,14 @@ export default class BaseDevice {
|
|||||||
notifyLogListeners(entry: DeviceLogEntry) {
|
notifyLogListeners(entry: DeviceLogEntry) {
|
||||||
this.logEntries.push(entry);
|
this.logEntries.push(entry);
|
||||||
if (this.logListeners.size > 0) {
|
if (this.logListeners.size > 0) {
|
||||||
this.logListeners.forEach(listener => listener(entry));
|
this.logListeners.forEach(listener => {
|
||||||
|
// prevent breaking other listeners, if one listener doesn't work.
|
||||||
|
try {
|
||||||
|
listener(entry);
|
||||||
|
} catch (e) {
|
||||||
|
console.error(`Log listener exception:`, e);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user