Move all error translations to common.errors.* in browser extension

This commit is contained in:
Leendert de Borst
2026-02-04 21:17:11 +01:00
parent 6dc9b638da
commit baa57623b7
5 changed files with 18 additions and 20 deletions

View File

@@ -40,7 +40,7 @@ const MobileUnlockModal: React.FC<IMobileUnlockModalProps> = ({
const getErrorMessage = (errorCode: MobileLoginErrorCode): string => {
switch (errorCode) {
case MobileLoginErrorCode.TIMEOUT:
return t('auth.errors.mobileLoginRequestExpired');
return t('common.errors.mobileLoginRequestExpired');
case MobileLoginErrorCode.GENERIC:
default:
return t('common.errors.unknownError');

View File

@@ -287,9 +287,9 @@ const Login: React.FC = () => {
setError(t('common.apiErrors.' + err.message));
} else if (hasErrorCode(err)) {
// Error contains an error code (E-XXX), show the formatted message as-is
setError(getErrorMessage(err, t('auth.errors.serverError')));
setError(getErrorMessage(err, t('common.errors.serverError')));
} else {
setError(t('auth.errors.serverError'));
setError(t('common.errors.serverError'));
}
hideLoading();
}
@@ -312,7 +312,7 @@ const Login: React.FC = () => {
// Validate that 2FA code is a 6-digit number
const code = twoFactorCode.trim();
if (!/^\d{6}$/.test(code)) {
throw new Error(t('auth.errors.invalidCode'));
throw new Error(t('common.errors.invalidCode'));
}
const twoFaUsername = SrpAuthService.normalizeUsername(credentials.username);
@@ -351,9 +351,9 @@ const Login: React.FC = () => {
setError(t('common.apiErrors.' + err.message));
} else if (hasErrorCode(err)) {
// Error contains an error code (E-XXX), show the formatted message as-is
setError(getErrorMessage(err, t('auth.errors.serverError')));
setError(getErrorMessage(err, t('common.errors.serverError')));
} else {
setError(t('auth.errors.serverError'));
setError(t('common.errors.serverError'));
}
hideLoading();
}

View File

@@ -281,7 +281,7 @@ const Unlock: React.FC = () => {
const sqliteClient = await dbContext.loadStoredDatabase();
if (!sqliteClient) {
// Edge case: no vault loaded but no error thrown (shouldn't happen)
throw new Error(t('auth.errors.wrongPassword'));
throw new Error(t('common.errors.wrongPassword'));
}
// Check if there are pending migrations
@@ -305,9 +305,9 @@ const Unlock: React.FC = () => {
await app.logout(err.message);
} else if (hasErrorCode(err)) {
// Error contains an error code (E-XXX), show the formatted message as-is
setError(getErrorMessage(err, t('auth.errors.wrongPassword')));
setError(getErrorMessage(err, t('common.errors.wrongPassword')));
} else {
setError(t('auth.errors.wrongPassword'));
setError(t('common.errors.wrongPassword'));
}
console.error('Unlock error:', err);
} finally {

View File

@@ -28,14 +28,7 @@
"switchAccounts": "Switch accounts?",
"loginWithMobile": "Log in using Mobile App",
"unlockWithMobile": "Unlock using Mobile App",
"scanQrCode": "Scan this QR code with your AliasVault mobile app to log in and unlock your vault.",
"errors": {
"invalidCode": "Please enter a valid 6-digit authentication code.",
"serverError": "Could not reach AliasVault server. Please try again later or contact support if the problem persists.",
"wrongPassword": "Incorrect password. Please try again.",
"sessionExpired": "Your session has expired. Please log in again.",
"mobileLoginRequestExpired": "Mobile login request timed out. Please reload the page and try again."
}
"scanQrCode": "Scan this QR code with your AliasVault mobile app to log in and unlock your vault."
},
"menu": {
"vault": "Vault",
@@ -106,7 +99,12 @@
"vaultIsLocked": "Vault is locked",
"passwordChanged": "Your password has changed since the last time you logged in. Please login again for security reasons.",
"syncConflictMaxRetries": "Could not sync vault after multiple attempts. Please try again later.",
"mergeFailed": "Failed to merge vault changes. Please try again."
"mergeFailed": "Failed to merge vault changes. Please try again.",
"invalidCode": "Please enter a valid 6-digit authentication code.",
"serverError": "Could not reach AliasVault server. Please try again later or contact support if the problem persists.",
"wrongPassword": "Incorrect password. Please try again.",
"sessionExpired": "Your session has expired. Please log in again.",
"mobileLoginRequestExpired": "Mobile login request timed out. Please reload the page and try again."
},
"apiErrors": {
"UNKNOWN_ERROR": "An unknown error occurred. Please try again.",

View File

@@ -78,7 +78,7 @@ export class WebApiService {
return parseJson ? retryResponse.json() : retryResponse as unknown as T;
} else {
logoutEventEmitter.emit('auth.errors.sessionExpired');
logoutEventEmitter.emit('common.errors.sessionExpired');
throw new ApiAuthError('Session expired');
}
}
@@ -281,7 +281,7 @@ export class WebApiService {
this.updateTokens(tokenResponse.token, tokenResponse.refreshToken);
return tokenResponse.token;
} catch {
logoutEventEmitter.emit('auth.errors.sessionExpired');
logoutEventEmitter.emit('common.errors.sessionExpired');
return null;
}
}