mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-12 17:45:22 +00:00
remove use of deprecated DomException code property
This commit is contained in:
committed by
David Lechner
parent
eb26bfcf1b
commit
db43cb3e99
+5
-20
@@ -133,10 +133,7 @@ function* handleBleConnectPybricks(): Generator {
|
||||
],
|
||||
})
|
||||
.catch((err) => {
|
||||
if (
|
||||
err instanceof DOMException &&
|
||||
err.code === DOMException.NOT_FOUND_ERR
|
||||
) {
|
||||
if (err instanceof DOMException && err.name === 'NotFoundError') {
|
||||
// this means the user clicked the cancel button in the scan dialog
|
||||
return undefined;
|
||||
}
|
||||
@@ -192,10 +189,7 @@ function* handleBleConnectPybricks(): Generator {
|
||||
|
||||
const deviceInfoService = yield* call(() =>
|
||||
server.getPrimaryService(deviceInformationServiceUUID).catch((err) => {
|
||||
if (
|
||||
err instanceof DOMException &&
|
||||
err.code === DOMException.NOT_FOUND_ERR
|
||||
) {
|
||||
if (err instanceof DOMException && err.name === 'NotFoundError') {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -263,10 +257,7 @@ function* handleBleConnectPybricks(): Generator {
|
||||
|
||||
const pnpIdChar = yield* call(() =>
|
||||
deviceInfoService.getCharacteristic(pnpIdUUID).catch((err) => {
|
||||
if (
|
||||
err instanceof DOMException &&
|
||||
err.code === DOMException.NOT_FOUND_ERR
|
||||
) {
|
||||
if (err instanceof DOMException && err.name === 'NotFoundError') {
|
||||
// istanbul ignore if
|
||||
if (process.env.NODE_ENV !== 'test') {
|
||||
console.warn(
|
||||
@@ -288,10 +279,7 @@ function* handleBleConnectPybricks(): Generator {
|
||||
|
||||
const pybricksService = yield* call(() =>
|
||||
server.getPrimaryService(pybricksServiceUUID).catch((err) => {
|
||||
if (
|
||||
err instanceof DOMException &&
|
||||
err.code === DOMException.NOT_FOUND_ERR
|
||||
) {
|
||||
if (err instanceof DOMException && err.name === 'NotFoundError') {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -353,10 +341,7 @@ function* handleBleConnectPybricks(): Generator {
|
||||
|
||||
const uartService = yield* call(() =>
|
||||
server.getPrimaryService(nordicUartServiceUUID).catch((err) => {
|
||||
if (
|
||||
err instanceof DOMException &&
|
||||
err.code === DOMException.NOT_FOUND_ERR
|
||||
) {
|
||||
if (err instanceof DOMException && err.name === 'NotFoundError') {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
@@ -638,10 +638,7 @@ function* handleFlashUsbDfu(action: ReturnType<typeof firmwareFlashUsbDfu>): Gen
|
||||
],
|
||||
})
|
||||
.catch((err) => {
|
||||
if (
|
||||
err instanceof DOMException &&
|
||||
err.code === DOMException.NOT_FOUND_ERR
|
||||
) {
|
||||
if (err instanceof DOMException && err.name === 'NotFoundError') {
|
||||
// user clicked cancel button
|
||||
return undefined;
|
||||
}
|
||||
@@ -685,10 +682,7 @@ function* handleFlashUsbDfu(action: ReturnType<typeof firmwareFlashUsbDfu>): Gen
|
||||
|
||||
defer.push(() =>
|
||||
dfu.close().catch((err) => {
|
||||
if (
|
||||
err instanceof DOMException &&
|
||||
err.code === DOMException.NETWORK_ERR
|
||||
) {
|
||||
if (err instanceof DOMException && err.name === 'NetworkError') {
|
||||
// device was disconnected
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ function* handleConnect(): Generator {
|
||||
}),
|
||||
);
|
||||
} catch (err) {
|
||||
if (err instanceof DOMException && err.code === DOMException.NOT_FOUND_ERR) {
|
||||
if (err instanceof DOMException && err.name === 'NotFoundError') {
|
||||
// this can happen if the use cancels the dialog
|
||||
yield* put(didFailToConnect(Reason.Canceled));
|
||||
} else {
|
||||
@@ -119,7 +119,7 @@ function* handleConnect(): Generator {
|
||||
} catch (err) {
|
||||
server.disconnect();
|
||||
yield* takeMaybe(disconnectChannel);
|
||||
if (err instanceof DOMException && err.code === DOMException.NOT_FOUND_ERR) {
|
||||
if (err instanceof DOMException && err.name === 'NotFoundError') {
|
||||
yield* put(didFailToConnect(Reason.GattServiceNotFound));
|
||||
} else {
|
||||
yield* put(didFailToConnect(Reason.Unknown, ensureError(err)));
|
||||
|
||||
Reference in New Issue
Block a user