Skip to content

Commit

Permalink
Add validation for no ports
Browse files Browse the repository at this point in the history
  • Loading branch information
radurentea committed May 30, 2024
1 parent 77e0c21 commit 0faf957
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/espIdf/serial/serialPort.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ export class SerialPort {
try {
const listOfSerialPorts = await SerialPortLib.SerialPort.list();

if (!listOfSerialPorts || listOfSerialPorts.length === 0) {
reject(new Error('No serial ports found'));
return;
}

const choices = listOfSerialPorts.map((item) => {
return new SerialPortDetails(
item.path,
Expand Down

0 comments on commit 0faf957

Please sign in to comment.