From 31b5dc389562f74f6b1e128b6a75b3225ae0c02c Mon Sep 17 00:00:00 2001 From: Jonathan Carter Date: Wed, 23 Mar 2016 10:49:52 -0700 Subject: [PATCH 1/4] Improving error message for invalid updates --- .../java/com/microsoft/codepush/react/CodePushPackage.java | 2 +- ios/CodePush/CodePushPackage.m | 4 +++- package-mixins.js | 6 +++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/android/app/src/main/java/com/microsoft/codepush/react/CodePushPackage.java b/android/app/src/main/java/com/microsoft/codepush/react/CodePushPackage.java index a9483b4..dc8218e 100644 --- a/android/app/src/main/java/com/microsoft/codepush/react/CodePushPackage.java +++ b/android/app/src/main/java/com/microsoft/codepush/react/CodePushPackage.java @@ -246,7 +246,7 @@ public class CodePushPackage { String relativeBundlePath = CodePushUpdateUtils.findJSBundleInUpdateContents(newUpdateFolderPath, expectedBundleFileName); if (relativeBundlePath == null) { - throw new CodePushInvalidUpdateException("Update is invalid - no files with extension .bundle, .js or .jsbundle were found in the update package."); + throw new CodePushInvalidUpdateException("Update is invalid - A JS bundle file named \"" + expectedBundleFileName + "\" could not be found within the downloaded contents. Please check that you are releasing your CodePush updates using the exact same JS bundle file name that was shipped with your app's binary."); } else { if (FileUtils.fileAtPathExists(newUpdateMetadataPath)) { File metadataFileFromOldUpdate = new File(newUpdateMetadataPath); diff --git a/ios/CodePush/CodePushPackage.m b/ios/CodePush/CodePushPackage.m index a0658cc..cba883f 100644 --- a/ios/CodePush/CodePushPackage.m +++ b/ios/CodePush/CodePushPackage.m @@ -207,7 +207,9 @@ static NSString *const UnzippedFolderName = @"unzipped"; if (relativeBundlePath) { [mutableUpdatePackage setValue:relativeBundlePath forKey:RelativeBundlePathKey]; } else { - error = [CodePushErrorUtils errorWithMessage:@"Update is invalid - no files with extension .jsbundle or .bundle were found in the update package."]; + NSString *errorMessage = [NSString stringWithFormat:@"Update is invalid - A JS bundle file named \"%@\" could not be found within the downloaded contents. Please check that you are releasing your CodePush updates using the exact same JS bundle file name that was shipped with your app's binary.", expectedBundleFileName]; + + error = [CodePushErrorUtils errorWithMessage:errorMessage]; failCallback(error); return; diff --git a/package-mixins.js b/package-mixins.js index 4c68404..604c386 100644 --- a/package-mixins.js +++ b/package-mixins.js @@ -27,8 +27,12 @@ module.exports = (NativeCodePush) => { const downloadedPackage = await NativeCodePush.downloadUpdate(this); reportStatusDownload && reportStatusDownload(this); return { ...downloadedPackage, ...local }; + } catch (e) { + // Rethrow the error so that the caller of this method + // is aware of the issue (e.g. the update was invalid) + throw e; } finally { - downloadProgressSubscription && downloadProgressSubscription.remove(); + downloadProgressSubscription && downloadProgressSubscription.remove(); } }, From 226f398ea849bf731e66dca56f994db5de543a75 Mon Sep 17 00:00:00 2001 From: Jonathan Carter Date: Wed, 23 Mar 2016 11:20:05 -0700 Subject: [PATCH 2/4] Reverting rethrow --- package-mixins.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/package-mixins.js b/package-mixins.js index 604c386..f3b2730 100644 --- a/package-mixins.js +++ b/package-mixins.js @@ -27,11 +27,8 @@ module.exports = (NativeCodePush) => { const downloadedPackage = await NativeCodePush.downloadUpdate(this); reportStatusDownload && reportStatusDownload(this); return { ...downloadedPackage, ...local }; - } catch (e) { - // Rethrow the error so that the caller of this method - // is aware of the issue (e.g. the update was invalid) - throw e; - } finally { + } + finally { downloadProgressSubscription && downloadProgressSubscription.remove(); } }, From ff59cf55e958a823a403f19339e68c41f4a06c6d Mon Sep 17 00:00:00 2001 From: Jonathan Carter Date: Wed, 23 Mar 2016 11:21:01 -0700 Subject: [PATCH 3/4] Fixing spacing --- package-mixins.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package-mixins.js b/package-mixins.js index f3b2730..3a83c29 100644 --- a/package-mixins.js +++ b/package-mixins.js @@ -27,8 +27,7 @@ module.exports = (NativeCodePush) => { const downloadedPackage = await NativeCodePush.downloadUpdate(this); reportStatusDownload && reportStatusDownload(this); return { ...downloadedPackage, ...local }; - } - finally { + } finally { downloadProgressSubscription && downloadProgressSubscription.remove(); } }, From 236b3ffbf1f00c2463641c9ca1c3fa20a7ef3c11 Mon Sep 17 00:00:00 2001 From: Jonathan Carter Date: Wed, 23 Mar 2016 11:21:35 -0700 Subject: [PATCH 4/4] Fixing spacing --- package-mixins.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package-mixins.js b/package-mixins.js index 3a83c29..4c68404 100644 --- a/package-mixins.js +++ b/package-mixins.js @@ -28,7 +28,7 @@ module.exports = (NativeCodePush) => { reportStatusDownload && reportStatusDownload(this); return { ...downloadedPackage, ...local }; } finally { - downloadProgressSubscription && downloadProgressSubscription.remove(); + downloadProgressSubscription && downloadProgressSubscription.remove(); } },