Skip to content

Localize user-facing error messages; log developer details - #82

Merged
dadachi merged 1 commit into
mainfrom
fix/localize-error-messages
Oct 14, 2026
Merged

dadachi merged 1 commit into
mainfrom
fix/localize-error-messages

Conversation

@dadachi

@dadachi dadachi commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

Summary

User-facing CodedError text is now localized (en/ja, same wording as NativeAppTemplate-Free-iOS); developer details go to the log. Error codes are unchanged.

Case Before After (en / ja)
No response (IOException: no network, timeout) or error status without a message (e.g. 502 HTML) — NATIVEAPPTEMPLATE-2002 Processing error: Unable to resolve host … / Processing error: HTTP 502 "Something went wrong while communicating with the server. Please try again later." / 「サーバーとの通信中に問題が発生しました。しばらくしてからもう一度お試しください。」
Response the app can't process (decode failure, missing fields) — 2002; 1001 Processing error: … / Unexpected error: … "An unexpected error occurred." / 「予期しないエラーが発生しました。」
Server error_message — 2001 <message> [Status: 422] <message> (status logged)
devise_token_auth message — 2002 Processing error: <message> <message>
  • ApiException.UnprocessableError.userMessage (Server / CommunicationFailure / Unexpected) says which one a 2002 is.
  • ErrorMessages resolves the strings with the application Context installed first thing in Application.onCreate (errors are mostly made in the network layer without a Context). Resolved when read, so it follows the app language.
  • ApiException.logged() logs [code] <raw detail> (HTTP status) where the error is made (adb logcat -s ApiError).
  • New identifiers avoid the names nativeapptemplate-agent renames; the messages have no domain words.
  • AGENTS.md rule changed: user-facing error text is localized; developer details go to logs; NATIVEAPPTEMPLATE-nnnn codes stay untranslated. CHANGELOG updated.

Test plan

  • New/updated tests in CodedErrorTest (now Robolectric, incl. ja qualifier), ApiResponseExtensionsTest, LoginRepositoryImplTest, RepositoryRequestsTest, SignInEmailAndPasswordViewModelTest, ShopkeeperEditViewModelTest, TestErrors; seen red by breaking the string mapping, the IOException check, the status suffix and the devise mapping
  • scripts/pre-push passes (406 unit tests)
  • Pixel (app language ja), debug build pointed at localhost:8767 via adb reverse: nothing listening → [NATIVEAPPTEMPLATE-2002] サーバーとの通信中に問題が発生しました。…; a fake server answering 200 with non-JSON → [NATIVEAPPTEMPLATE-2002] 予期しないエラーが発生しました。. Normal build against the local API: wrong password → [NATIVEAPPTEMPLATE-2001] メールアドレスまたはパスワードが正しくありません。もう一度お試しください。 (no " [Status: 401]"), then signed in.

🤖 Generated with Claude Code

https://claude.ai/code/session_01K5hZEFqXhBsUQwSWsgR6eH

What the user sees is now in the app language, with the iOS wording; the
error codes are unchanged:
- 2002 with no response (IOException) or an error status without a
  message: "Something went wrong while communicating with the server.
  Please try again later."
- 2002 for a response the app could not process, and 1001: "An
  unexpected error occurred."
- 2001 and devise's message: the server's message as is, without
  " [Status: nnn]" or "Processing error: ".

The raw detail and HTTP status stay in Throwable.message and are logged
with the code where the error is made (ApiException.logged(), tag
ApiError). ErrorMessages resolves the strings with the application
Context installed in Application.onCreate, since most errors are made
without a Context.

AGENTS.md: user-facing error text is localized; developer details go to
logs; NATIVEAPPTEMPLATE-nnnn codes stay untranslated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K5hZEFqXhBsUQwSWsgR6eH
@dadachi
dadachi merged commit ec8b08e into main Oct 14, 2026
1 check passed
@dadachi
dadachi deleted the fix/localize-error-messages branch October 14, 2026 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant