Repository navigation
Expand file tree
/
Copy pathErrorCodes.java
More file actions
57 lines (53 loc) Β· 2.46 KB
/
Copy pathErrorCodes.java
File metadata and controls
57 lines (53 loc) Β· 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package cn.reactnative.modules.update;
/**
* Stable, machine-readable error codes used as the promise rejection code so
* the JS layer and user loggers can aggregate errors across platforms.
*
* The codes of cpp/patch_core/error_codes.h and src/error.ts
* (UpdateErrorCode), all generated from scripts/contract.ts. Messages are
* free-form; only the codes are part of the contract.
*/
final class ErrorCodes {
// <generated:error-codes> (scripts/contract.ts; bun scripts/generate-contract.ts)
static final String INVALID_OPTIONS = "INVALID_OPTIONS";
static final String DOWNLOAD_FAILED = "DOWNLOAD_FAILED";
// Encoded (see Texts.reveal): the value is "PATCH_FAILED".
static final String DELTA_FAILED = Texts.reveal("0a36c0f286b44e640b1339dd");
static final String FILE_OPERATION_FAILED = "FILE_OPERATION_FAILED";
static final String SWITCH_VERSION_FAILED = "SWITCH_VERSION_FAILED";
static final String MARK_SUCCESS_FAILED = "MARK_SUCCESS_FAILED";
static final String RESTART_FAILED = "RESTART_FAILED";
static final String RESET_FAILED = "RESET_FAILED";
static final String INVALID_HASH_INFO = "INVALID_HASH_INFO";
static final String UNSUPPORTED_PLATFORM = "UNSUPPORTED_PLATFORM";
static final String APK_INSTALL_PERMISSION_REQUIRED = "APK_INSTALL_PERMISSION_REQUIRED";
static final String APK_INSTALL_FAILED = "APK_INSTALL_FAILED";
// </generated:error-codes>
private ErrorCodes() {
}
/**
* Rejection code of a failed download task, from DownloadTask's
* classification: post-download failures (unzip / hdiff / resource copy,
* incl. copiesCrc verification) are PATCH_FAILED so telemetry can
* separate patch health from network health; a local refusal
* (reinstalling the running version in place) is FILE_OPERATION_FAILED.
*/
static String forDownloadFailure(Throwable error) {
if (error instanceof PatchFailedException) {
return DELTA_FAILED;
}
if (error instanceof FileOperationException) {
return FILE_OPERATION_FAILED;
}
return DOWNLOAD_FAILED;
}
/**
* Whether another mirror of the same artifact can change the outcome
* (mirrors update_flow_core::IsMirrorRetryableCode and the JS
* isMirrorRetryableCode). A patch failure cannot: the bytes arrived and
* every mirror serves the same artifact.
*/
static boolean isMirrorRetryable(String code) {
return !DELTA_FAILED.equals(code);
}
}