@hot-updater/react-native
Version:
React Native OTA solution for self-hosted
54 lines (50 loc) • 2.25 kB
JavaScript
;
/**
* Hot Updater Error Codes
*
* This file defines all possible error codes that can be thrown by the native
* updateBundle function. These error codes are shared across iOS and Android
* implementations to ensure consistent error handling.
*
* Error Classification:
* - Parameter Validation: Invalid or missing function parameters
* - Bundle Storage: Errors during download, extraction, and storage
* - Signature Verification: Cryptographic verification failures (collapsed to a single public code)
* - Internal: Platform-specific or unexpected errors
*
* Retryability:
* - Retryable: DOWNLOAD_FAILED, INCOMPLETE_DOWNLOAD
* - Non-retryable: Most validation and verification errors
*/
export let HotUpdaterErrorCode = /*#__PURE__*/function (HotUpdaterErrorCode) {
HotUpdaterErrorCode["MISSING_BUNDLE_ID"] = "MISSING_BUNDLE_ID";
HotUpdaterErrorCode["INVALID_FILE_URL"] = "INVALID_FILE_URL";
HotUpdaterErrorCode["DIRECTORY_CREATION_FAILED"] = "DIRECTORY_CREATION_FAILED";
HotUpdaterErrorCode["DOWNLOAD_FAILED"] = "DOWNLOAD_FAILED";
HotUpdaterErrorCode["INCOMPLETE_DOWNLOAD"] = "INCOMPLETE_DOWNLOAD";
HotUpdaterErrorCode["EXTRACTION_FORMAT_ERROR"] = "EXTRACTION_FORMAT_ERROR";
HotUpdaterErrorCode["INVALID_BUNDLE"] = "INVALID_BUNDLE";
HotUpdaterErrorCode["INSUFFICIENT_DISK_SPACE"] = "INSUFFICIENT_DISK_SPACE";
HotUpdaterErrorCode["SIGNATURE_VERIFICATION_FAILED"] = "SIGNATURE_VERIFICATION_FAILED";
HotUpdaterErrorCode["MOVE_OPERATION_FAILED"] = "MOVE_OPERATION_FAILED";
HotUpdaterErrorCode["BUNDLE_IN_CRASHED_HISTORY"] = "BUNDLE_IN_CRASHED_HISTORY";
HotUpdaterErrorCode["SELF_DEALLOCATED"] = "SELF_DEALLOCATED";
HotUpdaterErrorCode["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
return HotUpdaterErrorCode;
}({});
/**
* Type guard to check if an error is a HotUpdaterError
*/
export function isHotUpdaterError(error) {
return typeof error === "object" && error !== null && "code" in error && typeof error.code === "string" && Object.values(HotUpdaterErrorCode).includes(error.code);
}
/**
* Base error class for Hot Updater
*/
export class HotUpdaterError extends Error {
constructor(message) {
super(message);
this.name = "HotUpdaterError";
}
}
//# sourceMappingURL=error.js.map