Skip to content

Commit 10cb072

Browse files
committed
improve errorUpdate message
1 parent a432e5f commit 10cb072

5 files changed

Lines changed: 28 additions & 20 deletions

File tree

Example/testHotUpdate/bun.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Example/testHotUpdate/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"react-native-paper": "^5.13.1",
2424
"react-native-safe-area-context": "^5.2.0",
2525
"react-native-svg": "^15.11.1",
26-
"react-native-update": "^10.25.0",
26+
"react-native-update": "^10.25.2",
2727
"react-native-vector-icons": "^10.2.0"
2828
},
2929
"devDependencies": {

android/src/main/java/cn/reactnative/modules/update/DownloadTask.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class DownloadTask extends AsyncTask<DownloadTaskParams, long[], Void> {
4949

5050
private void removeDirectory(File file) throws IOException {
5151
if (UpdateContext.DEBUG) {
52-
Log.d("RNUpdate", "Removing " + file);
52+
Log.d("react-native-update", "Removing " + file);
5353
}
5454
if (file.isDirectory()) {
5555
File[] files = file.listFiles();
@@ -88,7 +88,7 @@ private void downloadFile(DownloadTaskParams param) throws IOException {
8888
BufferedSink sink = Okio.buffer(Okio.sink(writePath));
8989

9090
if (UpdateContext.DEBUG) {
91-
Log.d("RNUpdate", "Downloading " + url);
91+
Log.d("react-native-update", "Downloading " + url);
9292
}
9393

9494
long bytesRead = 0;
@@ -98,7 +98,7 @@ private void downloadFile(DownloadTaskParams param) throws IOException {
9898
received += bytesRead;
9999
sink.emit();
100100
if (UpdateContext.DEBUG) {
101-
Log.d("RNUpdate", "Progress " + received + "/" + contentLength);
101+
Log.d("react-native-update", "Progress " + received + "/" + contentLength);
102102
}
103103

104104
int percentage = (int)(received * 100.0 / contentLength + 0.5);
@@ -115,7 +115,7 @@ private void downloadFile(DownloadTaskParams param) throws IOException {
115115
sink.close();
116116

117117
if (UpdateContext.DEBUG) {
118-
Log.d("RNUpdate", "Download finished");
118+
Log.d("react-native-update", "Download finished");
119119
}
120120
}
121121

@@ -244,7 +244,7 @@ private void doFullPatch(DownloadTaskParams param) throws IOException {
244244

245245

246246
if (UpdateContext.DEBUG) {
247-
Log.d("RNUpdate", "Unzip finished");
247+
Log.d("react-native-update", "Unzip finished");
248248
}
249249
}
250250

@@ -260,7 +260,7 @@ private void copyFromResource(HashMap<String, ArrayList<File> > resToCopy) throw
260260
File lastTarget = null;
261261
for (File target: targets) {
262262
if (UpdateContext.DEBUG) {
263-
Log.d("RNUpdate", "Copying from resource " + fn + " to " + target);
263+
Log.d("react-native-update", "Copying from resource " + fn + " to " + target);
264264
}
265265
if (lastTarget != null) {
266266
copyFile(lastTarget, target);
@@ -352,7 +352,7 @@ private void doPatchFromApk(DownloadTaskParams param) throws IOException, JSONEx
352352
copyFromResource(copyList);
353353

354354
if (UpdateContext.DEBUG) {
355-
Log.d("RNUpdate", "Unzip finished");
355+
Log.d("react-native-update", "Unzip finished");
356356
}
357357

358358
}
@@ -418,12 +418,12 @@ private void doPatchFromPpk(DownloadTaskParams param) throws IOException, JSONEx
418418
throw new Error("bundle patch not found");
419419
}
420420
if (UpdateContext.DEBUG) {
421-
Log.d("RNUpdate", "Unzip finished");
421+
Log.d("react-native-update", "Unzip finished");
422422
}
423423
}
424424
private void doCleanUp(DownloadTaskParams param) throws IOException {
425425
if (UpdateContext.DEBUG) {
426-
Log.d("RNUpdate", "Start cleaning up");
426+
Log.d("react-native-update", "Start cleaning up");
427427
}
428428
File root = param.unzipDirectory;
429429
for (File sub : root.listFiles()) {
@@ -499,7 +499,7 @@ protected Void doInBackground(DownloadTaskParams... params) {
499499
default:
500500
break;
501501
}
502-
Log.e("pushy", "download task failed", e);
502+
Log.e("react-native-update", "download task failed", e);
503503

504504
if (params[0].listener != null) {
505505
params[0].listener.onDownloadFailed(e);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-update",
3-
"version": "10.25.2",
3+
"version": "10.25.3",
44
"description": "react-native hot update",
55
"main": "src/index",
66
"scripts": {

src/client.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ export class Pushy {
361361
let succeeded = '';
362362
this.report({ type: 'downloading' });
363363
let lastError: any;
364+
let errorMessages: string[] = [];
364365
const diffUrl = await testUrls(joinUrls(paths, diff));
365366
if (diffUrl) {
366367
log('downloading diff');
@@ -372,11 +373,13 @@ export class Pushy {
372373
});
373374
succeeded = 'diff';
374375
} catch (e: any) {
375-
lastError = e;
376+
const errorMessage = `diff error: ${e.message}`;
377+
errorMessages.push(errorMessage);
378+
lastError = new Error(errorMessage);
376379
if (__DEV__) {
377380
succeeded = 'diff';
378381
} else {
379-
log(`diff error: ${e.message}, try pdiff`);
382+
log(errorMessage);
380383
}
381384
}
382385
}
@@ -390,11 +393,13 @@ export class Pushy {
390393
});
391394
succeeded = 'pdiff';
392395
} catch (e: any) {
393-
lastError = e;
396+
const errorMessage = `pdiff error: ${e.message}`;
397+
errorMessages.push(errorMessage);
398+
lastError = new Error(errorMessage);
394399
if (__DEV__) {
395400
succeeded = 'pdiff';
396401
} else {
397-
log(`pdiff error: ${e.message}, try full patch`);
402+
log(errorMessage);
398403
}
399404
}
400405
}
@@ -408,11 +413,13 @@ export class Pushy {
408413
});
409414
succeeded = 'full';
410415
} catch (e: any) {
411-
lastError = e;
416+
const errorMessage = `full patch error: ${e.message}`;
417+
errorMessages.push(errorMessage);
418+
lastError = new Error(errorMessage);
412419
if (__DEV__) {
413420
succeeded = 'full';
414421
} else {
415-
log(`full patch error: ${e.message}`);
422+
log(errorMessage);
416423
}
417424
}
418425
}
@@ -427,6 +434,7 @@ export class Pushy {
427434
this.report({
428435
type: 'errorUpdate',
429436
data: { newVersion: hash },
437+
message: errorMessages.join(';'),
430438
});
431439
if (lastError) {
432440
throw lastError;

0 commit comments

Comments
 (0)