Do not silently ignore errors not caused by user closing picker (#115)

This commit is contained in:
Paulus Schoutsen 2021-11-11 17:06:35 -08:00 committed by GitHub
parent a8dc857f26
commit ddbe525c99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,8 +5,11 @@ export const connect = async (button: InstallButton) => {
let port: SerialPort | undefined;
try {
port = await navigator.serial.requestPort();
} catch (err) {
console.error("User cancelled request", err);
} catch (err: any) {
if ((err as DOMException).name === "NotFoundError") {
return;
}
alert(`Error: ${err.message}`);
return;
}