diff --git a/README.md b/README.md index 31aece6..4ce3864 100644 --- a/README.md +++ b/README.md @@ -41,4 +41,4 @@ import { EnttecOpenDMXUSBDevice as DMXDevice } from "enttec-open-dmx-usb"; ## Events `ready` - `startSending` can be called. -`error` - An error occurred. +`error` - An error occurred. The error can also originate from SerialPort. diff --git a/src/index.ts b/src/index.ts index 2b197fa..c967f92 100644 --- a/src/index.ts +++ b/src/index.ts @@ -35,6 +35,13 @@ export class EnttecOpenDMXUSBDevice extends EventEmitter { this.emit("ready") if (startSending) this.startSending(0) }) + // Forward SerialPort errors. + // If nothing is attaching to the SerialPort error event, the Node process will be terminated + // in case of an error (e.g. wrong device passed) which would not permit error handling in + // projects using this package. + this.port.on("error", (error: Error) => { + this.emit("error", error) + }) } /**