show error message if failed to connect to device

This commit is contained in:
liamcottle
2025-02-13 14:37:19 +13:00
parent 474cbf31d9
commit deb7cb9374

View File

@@ -10,9 +10,20 @@ class Connection {
await this.connect(await BleConnection.open()); await this.connect(await BleConnection.open());
return true; return true;
} catch(e) { } catch(e) {
console.log(e); console.log(e);
// ignore device not selected error
if(e.name === "NotFoundError"){
return false; return false;
} }
// show error message
alert("failed to connect to ble device!");
return false;
}
} }
static async connectViaSerial() { static async connectViaSerial() {
@@ -20,9 +31,20 @@ class Connection {
await this.connect(await SerialConnection.open()); await this.connect(await SerialConnection.open());
return true; return true;
} catch(e) { } catch(e) {
console.log(e); console.log(e);
// ignore device not selected error
if(e.name === "NotFoundError"){
return false; return false;
} }
// show error message
alert("failed to connect to serial device!");
return false;
}
} }
static async connect(connection) { static async connect(connection) {