Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit 31b5dc3

Browse files
committed
Improving error message for invalid updates
1 parent e717eb0 commit 31b5dc3

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

android/app/src/main/java/com/microsoft/codepush/react/CodePushPackage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ public void downloadPackage(ReadableMap updatePackage, String expectedBundleFile
246246
String relativeBundlePath = CodePushUpdateUtils.findJSBundleInUpdateContents(newUpdateFolderPath, expectedBundleFileName);
247247

248248
if (relativeBundlePath == null) {
249-
throw new CodePushInvalidUpdateException("Update is invalid - no files with extension .bundle, .js or .jsbundle were found in the update package.");
249+
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.");
250250
} else {
251251
if (FileUtils.fileAtPathExists(newUpdateMetadataPath)) {
252252
File metadataFileFromOldUpdate = new File(newUpdateMetadataPath);

ios/CodePush/CodePushPackage.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,9 @@ + (void)downloadPackage:(NSDictionary *)updatePackage
207207
if (relativeBundlePath) {
208208
[mutableUpdatePackage setValue:relativeBundlePath forKey:RelativeBundlePathKey];
209209
} else {
210-
error = [CodePushErrorUtils errorWithMessage:@"Update is invalid - no files with extension .jsbundle or .bundle were found in the update package."];
210+
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];
211+
212+
error = [CodePushErrorUtils errorWithMessage:errorMessage];
211213

212214
failCallback(error);
213215
return;

package-mixins.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,12 @@ module.exports = (NativeCodePush) => {
2727
const downloadedPackage = await NativeCodePush.downloadUpdate(this);
2828
reportStatusDownload && reportStatusDownload(this);
2929
return { ...downloadedPackage, ...local };
30+
} catch (e) {
31+
// Rethrow the error so that the caller of this method
32+
// is aware of the issue (e.g. the update was invalid)
33+
throw e;
3034
} finally {
31-
downloadProgressSubscription && downloadProgressSubscription.remove();
35+
downloadProgressSubscription && downloadProgressSubscription.remove();
3236
}
3337
},
3438

0 commit comments

Comments
 (0)