Skip to content

Localize alert error fallbacks instead of error.toString() - #3464

Merged
feruzm merged 2 commits into
developmentfrom
bugfix/alert-error-fallbacks
Aug 6, 2026
Merged

Localize alert error fallbacks instead of error.toString()#3464
feruzm merged 2 commits into
developmentfrom
bugfix/alert-error-fallbacks

Conversation

@feruzm

@feruzm feruzm commented Aug 6, 2026

Copy link
Copy Markdown
Member

Closes #2684

Sixteen user-facing alerts across eleven files fell back to error.toString() or String(err) for the message body, which shows raw stringified output when a throw carries no message (worst case [object Object]). All of them now fall back to the existing alert.unknow_error locale string ("An error occurred"), keeping the real error.message when present.

  • spinGameContainer had no intl access and gains useIntl for its three alert sites; transferContainer's class site uses its injected intl.
  • The toString() uses that only sniff status codes (409/413 matching in editorQueries and uploadsGalleryModal) are matching logic, not user-facing text, and are untouched. mediaPickerError's internal normalizer is also out of scope since it feeds its own message-mapping table.

Zero typecheck errors; behavior change is limited to what the fallback string says.

Summary by CodeRabbit

  • Bug Fixes
    • Improved error alerts across profile, upload, transfer, community, and game actions.
    • Displays clearer localized fallback messaging when specific error details are unavailable.
    • Preserves available error messages while avoiding unclear technical error text.
    • Improved consistency of save-failure alerts.
    • Improved error reporting to help diagnose failures across key actions.

Second commit (937eaee), addressing review feedback: the generic fallback also hides diagnostics from screenshots, so every one of the sixteen catch sites now reports the error to Sentry via the typed helper with a context tag naming the flow (spin-game-status, transfer-points-balance, profile-fetch, profile-favorite, delegate-broadcast, power-down-broadcast, withdraw-routes-fetch, community-role-update, media-upload-batch and so on) before alerting. Thirteen of the sixteen previously reported nothing anywhere, including the delegation and power-down broadcast failures. If user-cancelled broadcasts turn out to flood any of these tags, filtering by tag in Sentry is now a one-liner.

Sixteen user-facing alerts fell back to error.toString() or String(err),
which surfaces raw stringified objects when a throw has no message. All now
fall back to the alert.unknow_error locale string. spinGameContainer gains
useIntl; the matching-only toString() uses (status-code sniffing) are
untouched.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The changes add Sentry exception capture with operation-specific context tags across profile, game, transfer, modal, and community handlers. Error alerts now use localized alert.unknow_error fallbacks when exceptions have no message.

Changes

Error handling updates

Layer / File(s) Summary
Profile error reporting
src/components/organisms/quickProfileModal/children/quickProfileContent.tsx, src/containers/profileContainer.tsx, src/containers/profileEditContainer.tsx
Profile fetch, action, favorite, quick-profile, and image-upload failures now capture exceptions with context tags. Alerts retain error.message when available and use the localized fallback otherwise.
Game and points-transfer error reporting
src/containers/spinGameContainer.ts, src/containers/transferContainer.ts
Redeem status, game-start, claim, and points-balance failures now capture exceptions with operation-specific tags and use localized fallback alerts.
Modal and screen error reporting
src/components/postOptionsModal/container/postOptionsModal.tsx, src/components/uploadsGalleryModal/container/uploadsGalleryModal.tsx, src/screens/communityMembers/screen/communityMembersScreen.tsx, src/screens/communitySettings/screen/communitySettingsScreen.tsx, src/screens/transfer/screen/delegateScreen.tsx, src/screens/transfer/screen/powerDownScreen.tsx
Modal and screen failures now capture exceptions with context tags and replace raw error-string fallbacks with localized unknown-error messages.

Estimated code review effort: 2 (Simple) | ~15 minutes

Possibly related PRs

  • ecency/vision-mobile#3461: Both changes standardize Sentry exception reporting with shared captureException usage and contextual tags.

Poem

A rabbit reports each error hop,
With tagged exceptions sent nonstop.
If messages hide, alerts stay clear,
A translated fallback appears here.
“No raw strings!” cheers the hare.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The Sentry captureException additions are not required by issue #2684 and introduce unrelated diagnostic behavior across the affected catch sites. Move the Sentry reporting changes to a separate pull request or link an issue that explicitly requires flow-specific Sentry capture.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes replace error.toString() and String(err) fallbacks with the localized alert.unknow_error message as required by issue #2684.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the primary change: replacing error.toString() fallbacks with localized alert errors.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bugfix/alert-error-fallbacks

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/containers/spinGameContainer.ts (1)

39-44: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Keep intl current in asynchronous handlers.

_statusCheck and the claim effect close over the intl instance from their render. If the user switches language while a request is in flight, these catch blocks can display alert.unknow_error in the old locale. Store the latest intl in a ref and use it in these catch blocks.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/containers/spinGameContainer.ts` around lines 39 - 44, Update the
asynchronous _statusCheck handler and claim effect in the spin game container to
keep the latest intl instance in a ref, refreshing that ref when intl changes.
Use the ref’s current value when formatting alert.unknow_error in both catch
blocks so in-flight requests display the current locale.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/containers/spinGameContainer.ts`:
- Around line 39-44: Update the asynchronous _statusCheck handler and claim
effect in the spin game container to keep the latest intl instance in a ref,
refreshing that ref when intl changes. Use the ref’s current value when
formatting alert.unknow_error in both catch blocks so in-flight requests display
the current locale.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 9af73ecb-821e-4b57-98fa-267452cca0b4

📥 Commits

Reviewing files that changed from the base of the PR and between 8dac936 and 208d18c.

📒 Files selected for processing (11)
  • src/components/organisms/quickProfileModal/children/quickProfileContent.tsx
  • src/components/postOptionsModal/container/postOptionsModal.tsx
  • src/components/uploadsGalleryModal/container/uploadsGalleryModal.tsx
  • src/containers/profileContainer.tsx
  • src/containers/profileEditContainer.tsx
  • src/containers/spinGameContainer.ts
  • src/containers/transferContainer.ts
  • src/screens/communityMembers/screen/communityMembersScreen.tsx
  • src/screens/communitySettings/screen/communitySettingsScreen.tsx
  • src/screens/transfer/screen/delegateScreen.tsx
  • src/screens/transfer/screen/powerDownScreen.tsx

The generic fallback hides diagnostics from users, so every one of the
sixteen catch sites now captures the error with a context tag naming the
flow (spin-game-status, transfer-points-balance, profile-fetch,
delegate-broadcast, power-down-broadcast, media-upload-batch and friends)
before alerting. Thirteen of them previously reported nothing anywhere.
@feruzm
feruzm merged commit afcfa71 into development Aug 6, 2026
11 of 12 checks passed
@feruzm
feruzm deleted the bugfix/alert-error-fallbacks branch August 6, 2026 06:33

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/containers/spinGameContainer.ts`:
- Around line 40-41: Update the _statusCheck and _startGame error handlers to
store the latest intl value in a ref before formatting alerts, then use that
current-locale ref for intl.formatMessage instead of the captured intl variable.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1eeb43d8-fa7f-4bd1-80db-d8a87b03eb0f

📥 Commits

Reviewing files that changed from the base of the PR and between 208d18c and 937eaee.

📒 Files selected for processing (11)
  • src/components/organisms/quickProfileModal/children/quickProfileContent.tsx
  • src/components/postOptionsModal/container/postOptionsModal.tsx
  • src/components/uploadsGalleryModal/container/uploadsGalleryModal.tsx
  • src/containers/profileContainer.tsx
  • src/containers/profileEditContainer.tsx
  • src/containers/spinGameContainer.ts
  • src/containers/transferContainer.ts
  • src/screens/communityMembers/screen/communityMembersScreen.tsx
  • src/screens/communitySettings/screen/communitySettingsScreen.tsx
  • src/screens/transfer/screen/delegateScreen.tsx
  • src/screens/transfer/screen/powerDownScreen.tsx
🚧 Files skipped from review as they are similar to previous changes (9)
  • src/containers/transferContainer.ts
  • src/components/uploadsGalleryModal/container/uploadsGalleryModal.tsx
  • src/containers/profileContainer.tsx
  • src/components/postOptionsModal/container/postOptionsModal.tsx
  • src/screens/transfer/screen/powerDownScreen.tsx
  • src/screens/communitySettings/screen/communitySettingsScreen.tsx
  • src/screens/communityMembers/screen/communityMembersScreen.tsx
  • src/screens/transfer/screen/delegateScreen.tsx
  • src/components/organisms/quickProfileModal/children/quickProfileContent.tsx

Comment on lines +40 to +41
captureException(err, (scope) => scope.setTag('context', 'spin-game-status'));
Alert.alert(get(err, 'message') || intl.formatMessage({ id: 'alert.unknow_error' }));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Locate and inspect the targeted file and relevant dependency-effect usages without executing repo code.
wc -l src/containers/spinGameContainer.ts || true
ast-grep outline src/containers/spinGameContainer.ts --view expanded || true
sed -n '1,150p' src/containers/spinGameContainer.ts

Repository: ecency/vision-mobile

Length of output: 3793


Use a current-locale intl ref in error-alert handlers.

_statusCheck and _startGame capture intl, so locale changes while the container remains mounted can show alerts in the previous locale. Store the current intl in a ref in both paths before using intl.formatMessage(...).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/containers/spinGameContainer.ts` around lines 40 - 41, Update the
_statusCheck and _startGame error handlers to store the latest intl value in a
ref before formatting alerts, then use that current-locale ref for
intl.formatMessage instead of the captured intl variable.

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.

Change Alert Error Message

1 participant