Skip to content

Commit 071a702

Browse files
authored
Handle errors opening the port (#105)
1 parent d109b76 commit 071a702

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/serial-provision-dialog.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,14 @@ class SerialProvisionDialog extends LitElement {
399399
}
400400

401401
private async _connect() {
402-
const client = new ImprovSerial(this.port!, this.logger);
402+
let client: ImprovSerial;
403+
try {
404+
client = new ImprovSerial(this.port!, this.logger);
405+
} catch (err) {
406+
this._state = "ERROR";
407+
this._error = (err as any).message || err || "Unknown error";
408+
return;
409+
}
403410
client.addEventListener("state-changed", () => {
404411
this._state = "IMPROV-STATE";
405412
this.requestUpdate();

0 commit comments

Comments
 (0)