From 0aec0980f6e54495a9e92bcc3c00e0536a4fb5fd Mon Sep 17 00:00:00 2001 From: keeramis Date: Fri, 28 Jun 2024 13:55:08 -0700 Subject: [PATCH] Error handling when flashing devices in Protected Mode --- src/cmd/usb-util.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/cmd/usb-util.js b/src/cmd/usb-util.js index 10a273499..61f1ee5a3 100644 --- a/src/cmd/usb-util.js +++ b/src/cmd/usb-util.js @@ -285,7 +285,10 @@ async function reopenInDfuMode(device) { } return device; } catch (error) { - // ignore error + // ignore other errors + if (error instanceof DeviceProtectionError) { + throw new Error('Operation cannot be completed due to Device Protection.'); + } } } throw new Error('Unable to reconnect to the device. Try again or run particle update to repair the device'); @@ -313,7 +316,9 @@ async function reopenInNormalMode(device, { reset } = {}) { } } } catch (err) { - // ignore error + // ignore other errors + if (err instanceof DeviceProtectionError) { + throw new Error('Operation cannot be completed due to Device Protection.'); } } throw new Error('Unable to reconnect to the device. Try again or run particle update to repair the device');