backup-errors.mjs (1512B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 import { ERRORS } from "chrome://browser/content/backup/backup-constants.mjs"; 6 7 /** 8 * Any recovery error messaging should be defined in Fluent with both 9 * a `heading` attribute and a `message` attribute. 10 */ 11 export const ERROR_L10N_IDS = Object.freeze({ 12 [ERRORS.UNAUTHORIZED]: "backup-service-error-incorrect-password", 13 [ERRORS.CORRUPTED_ARCHIVE]: "backup-service-error-corrupt-file", 14 [ERRORS.UNSUPPORTED_BACKUP_VERSION]: 15 "backup-service-error-unsupported-version", 16 [ERRORS.UNINITIALIZED]: "backup-service-error-went-wrong2", 17 [ERRORS.FILE_SYSTEM_ERROR]: "backup-service-error-went-wrong2", 18 [ERRORS.DECRYPTION_FAILED]: "backup-service-error-went-wrong2", 19 [ERRORS.RECOVERY_FAILED]: "backup-service-error-recovery-failed", 20 [ERRORS.UNKNOWN]: "backup-service-error-went-wrong2", 21 [ERRORS.INTERNAL_ERROR]: "backup-service-error-went-wrong2", 22 [ERRORS.UNSUPPORTED_APPLICATION]: 23 "backup-service-error-unsupported-application", 24 }); 25 26 /** 27 * @param {number} errorCode 28 * Error code from backup-constants.mjs:ERRORS 29 * @returns {string} 30 * L10N ID for error messaging for the given error code; the L10N 31 * ID should have both a `heading` and a `message` attribute 32 */ 33 export function getErrorL10nId(errorCode) { 34 return ERROR_L10N_IDS[errorCode] ?? ERROR_L10N_IDS[ERRORS.UNKNOWN]; 35 }