This commit is contained in:
Koen Kanters
2021-10-13 21:57:04 +02:00
parent cff4ea726e
commit 8fac172ced
2 changed files with 7 additions and 2 deletions
+4 -1
View File
@@ -50,7 +50,10 @@ class Controller {
private extensionArgs: ExtensionArgs;
constructor(restartCallback: () => void, exitCallback: (code: number) => void) {
this.eventBus = new EventBus();
this.eventBus = new EventBus( /* istanbul ignore next */ (error) => {
logger.error(`Error: ${error.message}`);
logger.debug(error.stack);
});
this.zigbee = new Zigbee(this.eventBus);
this.mqtt = new MQTT(this.eventBus);
this.state = new State(this.eventBus);
+3 -1
View File
@@ -1,4 +1,5 @@
import events from 'events';
events.captureRejections = true;
// eslint-disable-next-line
type ListenerKey = object;
@@ -7,8 +8,9 @@ export default class EventBus {
private callbacksByExtension: { [s: string]: { event: string, callback: (...args: unknown[]) => void }[] } = {};
private emitter = new events.EventEmitter();
constructor() {
constructor(onError: (error: Error) => void) {
this.emitter.setMaxListeners(100);
this.emitter.on('error', onError);
}
public emitAdapterDisconnected(): void {