diff --git a/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java b/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java index 604e60e3..c8f299e4 100644 --- a/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java +++ b/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java @@ -400,7 +400,13 @@ public void dispatchDownloadProgressEvent() { CodePushUtils.log(e); mSettingsManager.saveFailedUpdate(CodePushUtils.convertReadableToJsonObject(updatePackage)); promise.reject(e); - } catch (IOException | CodePushUnknownException e) { + } catch (IOException | CodePushUnknownException | CodePushMalformedDataException e) { + CodePushUtils.log(e); + promise.reject(e); + } catch (Exception e) { + // Safety net: make sure a download failure always rejects the JS promise + // instead of escaping this background task uncaught, which would leave + // the promise hanging forever with no error and no log tying it to a cause. CodePushUtils.log(e); promise.reject(e); } @@ -492,6 +498,12 @@ protected Void doInBackground(Void... params) { } catch(CodePushUnknownException e) { CodePushUtils.log(e); promise.reject(e); + } catch (Exception e) { + // Safety net: make sure a failure always rejects the JS promise + // instead of escaping this background task uncaught, which would leave + // the promise hanging forever with no error and no log tying it to a cause. + CodePushUtils.log(e); + promise.reject(e); } return null; @@ -550,6 +562,12 @@ protected Void doInBackground(Void... params) { } catch(CodePushUnknownException e) { CodePushUtils.log(e); promise.reject(e); + } catch (Exception e) { + // Safety net: make sure a failure always rejects the JS promise + // instead of escaping this background task uncaught, which would leave + // the promise hanging forever with no error and no log tying it to a cause. + CodePushUtils.log(e); + promise.reject(e); } return null; } @@ -634,7 +652,13 @@ public void onHostDestroy() { } promise.resolve(""); - } catch(CodePushUnknownException e) { + } catch (CodePushUnknownException | CodePushMalformedDataException e) { + CodePushUtils.log(e); + promise.reject(e); + } catch (Exception e) { + // Safety net: make sure an install failure always rejects the JS promise + // instead of escaping this background task uncaught, which would leave + // the promise hanging forever with no error and no log tying it to a cause. CodePushUtils.log(e); promise.reject(e); }