Skip to content

Commit

Permalink
Improve error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
SantaClaas committed Sep 15, 2023
1 parent c3438a4 commit 12db4a9
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/lib/SerialPorts.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,17 @@
// Known working usb devices
const portFilter = [{ usbVendorId: 6790, usbProductId: 29987 }];
function connect() {
navigator.serial.requestPort({ filters: portFilter }).then((port) => {
availablePorts.set(port, port.getInfo());
quickUpdateHack();
});
async function connect() {
let port;
try {
port = await navigator.serial.requestPort({ filters: portFilter });
} catch (error) {
console.warn("User cancelled port selection", error);
return;
}
availablePorts.set(port, port.getInfo());
quickUpdateHack();
}
function quickUpdateHack() {
Expand Down

0 comments on commit 12db4a9

Please sign in to comment.