-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/sc 124322/protected error #711
Conversation
buf = await device.readOverDfu({ altSetting, startAddr, size }); | ||
} catch (err) { | ||
throw new Error('Reading over DFU failed', err); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might as well throw an error here? So I added this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That doesn't look necessary. The previous code will throw an error if it fails already.
} finally { | ||
progress({ event: 'finish' }); | ||
progress({ event: 'finish', success }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The UI was looking a bit weird as it says Flash Success
and then Operation failed due to device protection
.
So I added Flash Failed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good now. Probably simplify the throw statements to just throw error
. Update particle-usb dependency then this is good to merge 👍
if (err instanceof DeviceProtectionError) { | ||
throw new Error('Operation could not be completed due to device protection.'); | ||
} | ||
throw new VError(ensureError(err), 'Writing over DFU failed'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a change in behavior. Previously it would have just thrown the error directly (i.e. throw err
). Does this change fix a specific thing you noticed during testing?
buf = await device.readOverDfu({ altSetting, startAddr, size }); | ||
} catch (err) { | ||
throw new Error('Reading over DFU failed', err); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That doesn't look necessary. The previous code will throw an error if it fails already.
if (error instanceof DeviceProtectionError) { | ||
throw new Error('Operation could not be completed due to device protection.'); | ||
} | ||
throw new VError(ensureError(error), 'Writing over DFU failed'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question here. Why use this vs throw error;
@@ -177,7 +194,7 @@ function _createFlashProgress({ flashSteps, ui }) { | |||
} | |||
break; | |||
case 'finish': | |||
description = 'Flash success!'; | |||
description = payload.success ? 'Flash success!' : 'Flash failed.'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good improvement.
ed541c0
to
9e73928
Compare
Description
CLI gives an error that device is protected if the device is protected.
How to Test
5.6.0
particle-cli
branch to use thisparticle-usb
PR - Add error code for protected devices particle-usb#97npm start -- flash --local
After testing, make sure you flash the device with a "good" device-os branch so you can resume flashing.
Related Issues / Discussions
Completeness