From 53c1f8fceec81526873e3b37b733888ce5867112 Mon Sep 17 00:00:00 2001 From: Samed Ozdemir Date: Sat, 27 Feb 2021 23:43:01 -0500 Subject: [PATCH] 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. --- src/secure-dfu.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/secure-dfu.ts b/src/secure-dfu.ts index 44edb3e..6947423 100644 --- a/src/secure-dfu.ts +++ b/src/secure-dfu.ts @@ -306,10 +306,12 @@ export class SecureDfu extends EventDispatcher { } private sendControl(operation: Array, buffer?: ArrayBuffer): Promise { - 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); }); }); }