diff --git a/src/connection/nodejs_serial_connection.js b/src/connection/nodejs_serial_connection.js index 4bc519d..3f3d617 100644 --- a/src/connection/nodejs_serial_connection.js +++ b/src/connection/nodejs_serial_connection.js @@ -30,8 +30,9 @@ class NodeJSSerialConnection extends SerialConnection { this.onDisconnected(); }); - this.serialPort.on("error", function(err) { - console.log("SerialPort Error: ", err.message) + this.serialPort.on("error", (error) => { + console.error("SerialPort Error: ", error.message); + this.emit("error", error); }); this.serialPort.on("data", async (data) => { diff --git a/src/connection/tcp_connection.js b/src/connection/tcp_connection.js index eab0e16..6747846 100644 --- a/src/connection/tcp_connection.js +++ b/src/connection/tcp_connection.js @@ -28,6 +28,7 @@ class TCPConnection extends Connection { // handle errors this.socket.on('error', (error) => { console.error('Connection Error', error); + this.emit("error", error); }); // handle socket close