sendControl causing "uncaught in promise" error

Ran into a case where errors in sendControl could not be handled.

Made change to explicitly handle and reject an errors happening in sendControl.
This commit is contained in:
Samed Ozdemir
2021-02-27 23:43:01 -05:00
committed by GitHub
parent 02d64e17af
commit 53c1f8fcee

View File

@@ -306,10 +306,12 @@ export class SecureDfu extends EventDispatcher {
}
private sendControl(operation: Array<number>, buffer?: ArrayBuffer): Promise<DataView> {
return new Promise(resolve => {
return new Promise((resolve, reject) => {
this.sendOperation(this.controlChar, operation, buffer)
.then(resp => {
setTimeout(() => resolve(resp), this.delay);
}).catch(err => {
reject(err);
});
});
}