refactor(android): error messages come from the web's copy, one source for both apps (DRY B6)
release / web (push) Successful in 1m27s
release / go (push) Successful in 1m54s
release / govulncheck (push) Successful in 18s
release / android (push) Failing after 1m10s
release / integration (push) Successful in 4m9s
release / Build signed APK (push) Successful in 4m43s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Skipped
release / Verify release artifacts (tag releases only) (push) Skipped

Android's ErrorCopy was a hand-kept copy of web/src/lib/styles/
error-copy.json that had drifted: 14 of the web's codes were missing
(a server shutting down, a bad setting value, the backup and duplicates
codes), so those read "Something went wrong." on the phone, and only 2
of the web's 7 codes appended the server's specifics.

Now app/build.gradle.kts copies error-copy.json and a new
error-detail-codes.json (the list web/src/lib/api/errors.ts kept
inline) into the app's Java resources, and ErrorCopy reads them. The
three codes only Android had (auth_required, not_found,
cleartext_public) move into the shared file. PasswordRules' too-short
line is the shared password_too_short copy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-27 14:11:34 -05:00
co-authored by Claude Opus 5.5
parent 25cee5ed69
commit 5d85739038
7 changed files with 100 additions and 69 deletions
+8 -16
View File
@@ -1,4 +1,5 @@
import { copyForCode } from './error-copy';
import detailCodesJson from '../styles/error-detail-codes.json';
/**
* Returns the `code` field from an unknown error value, or 'unknown'
@@ -12,23 +13,14 @@ export function errCode(err: unknown): string {
* Codes whose server message carries specifics an admin needs in order to
* act — which directory, which uid — that fixed copy cannot say. For these the
* message follows the copy. Kept to a named list on purpose: most
* server messages are internal detail and must never reach a toast. Mirrored
* in Android's ErrorCopy.
* server messages are internal detail and must never reach a toast. The list
* is styles/error-detail-codes.json, which Android's ErrorCopy reads too:
* library_not_writable and file_delete_failed name the directory and uid,
* invalid_setting the field and its range, invalid_public_url the address
* shape wanted, bad_folders the folder and its fault, invalid_backup_setting
* the setting and why, destination_failed the destination's own refusal.
*/
const DETAIL_CODES: ReadonlySet<string> = new Set([
'library_not_writable',
'file_delete_failed',
// The server names the field and its range.
'invalid_setting',
// The server says what shape of address it wants.
'invalid_public_url',
// The server names the folder and what is wrong with it.
'bad_folders',
// The server says which backup setting and why.
'invalid_backup_setting',
// The destination's own answer: the bucket's refusal, or the missing folder.
'destination_failed'
]);
const DETAIL_CODES: ReadonlySet<string> = new Set(detailCodesJson);
/**
* Returns user-facing copy for an unknown error value. Looks up the
+4 -1
View File
@@ -49,5 +49,8 @@
"destination_failed": "Couldn't reach the backup destination.",
"backup_running": "A backup is already running.",
"backup_not_ready": "Set up where backups go first.",
"shutting_down": "The server is shutting down. Try again in a moment."
"shutting_down": "The server is shutting down. Try again in a moment.",
"auth_required": "You need to sign in to do that.",
"not_found": "That no longer exists.",
"cleartext_public": "This server is on the internet, so its URL must start with https://. Plain http:// only works on your home network."
}
@@ -0,0 +1,9 @@
[
"library_not_writable",
"file_delete_failed",
"invalid_setting",
"invalid_public_url",
"bad_folders",
"invalid_backup_setting",
"destination_failed"
]