remove use of deprecated DomException code property

This commit is contained in:
David Lechner
2022-10-14 16:21:18 -05:00
committed by David Lechner
parent eb26bfcf1b
commit db43cb3e99
3 changed files with 9 additions and 30 deletions
+5 -20
View File
@@ -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;
}
+2 -8
View File
@@ -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;
}
+2 -2
View File
@@ -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)));