90 lines
2.6 KiB
TypeScript
90 lines
2.6 KiB
TypeScript
// Metro module 4091 (f4092).
|
|
import { DispatchErrorCodes } from "../modules/rpc/Constants";
|
|
import { intl, t } from "../intl/index.native";
|
|
import { formatSize } from "../utils/FileSizeUtils";
|
|
class NativeDispatchError {
|
|
constructor(a0) {
|
|
this.raw = a0;
|
|
if (a0.code != null) {
|
|
this.code = a0.code;
|
|
}
|
|
if (a0.uuid != null) {
|
|
this.uuid = a0.uuid;
|
|
}
|
|
if (a0.application_id != null) {
|
|
this.applicationId = a0.application_id;
|
|
}
|
|
if (a0.branch_id != null) {
|
|
this.branchId = a0.branch_id;
|
|
}
|
|
if (a0.context != null) {
|
|
this.context = a0.context;
|
|
} else {
|
|
this.context = {};
|
|
}
|
|
}
|
|
get displayMessage() {
|
|
if (this.code == null) {
|
|
return intl.string(t["5NMPSS"]);
|
|
}
|
|
const path = this.context.path;
|
|
const code = this.code;
|
|
if (DispatchErrorCodes.DISK_LOW === code) {
|
|
const context = this.context;
|
|
const { available, required } = context;
|
|
const available2 = formatSize(available, {
|
|
useKibibytes: true
|
|
});
|
|
return intl.formatToPlainString(t["2DR5dl"], {
|
|
required: formatSize(required, {
|
|
useKibibytes: true
|
|
}),
|
|
available: available2
|
|
});
|
|
}
|
|
if (DispatchErrorCodes.POST_INSTALL_FAILED === code) {
|
|
return intl.formatToPlainString(t.hP0B3A, {
|
|
name: this.context.name
|
|
});
|
|
}
|
|
if (DispatchErrorCodes.FILE_NAME_TOO_LONG === code) {
|
|
return intl.string(t["FWht5+"]);
|
|
}
|
|
if (DispatchErrorCodes.POST_INSTALL_CANCELLED === code) {
|
|
return intl.string(t["9CNxFJ"]);
|
|
}
|
|
if (DispatchErrorCodes.IO_PERMISSION_DENIED === code) {
|
|
return intl.string(t["PJx5+Z"]);
|
|
}
|
|
if (DispatchErrorCodes.NO_MANIFESTS === code) {
|
|
return intl.string(t.gLM395);
|
|
}
|
|
if (DispatchErrorCodes.NOT_ENTITLED === code) {
|
|
return intl.string(t.TLCR43);
|
|
}
|
|
if (DispatchErrorCodes.NOT_DIRECTORY !== code && DispatchErrorCodes.DISK_PERMISSION_DENIED !== code) {
|
|
if (DispatchErrorCodes.INVALID_DRIVE === code) {
|
|
return intl.formatToPlainString(t["08L2TG"], {
|
|
path
|
|
});
|
|
}
|
|
if (DispatchErrorCodes.APPLICATION_LOCK_FAILED === code) {
|
|
return intl.string(t.RDYCUV);
|
|
}
|
|
if (DispatchErrorCodes.DISK_FULL === code) {
|
|
return intl.string(t.mojtDJ);
|
|
}
|
|
if (DispatchErrorCodes.API_ERROR !== code && DispatchErrorCodes.MAX_REQUEST_RETRIES_EXCEEDED !== code) {
|
|
return intl.formatToPlainString(t.r477WB, {
|
|
code: `${this.code}`
|
|
});
|
|
}
|
|
return intl.string(t.OXD41D);
|
|
}
|
|
return intl.formatToPlainString(t.EjWbO6, {
|
|
path
|
|
});
|
|
}
|
|
}
|
|
export default NativeDispatchError;
|