Localize alert error fallbacks instead of error.toString() - #3464
Conversation
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.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
📝 WalkthroughWalkthroughThe changes add Sentry exception capture with operation-specific context tags across profile, game, transfer, modal, and community handlers. Error alerts now use localized ChangesError handling updates
Estimated code review effort: 2 (Simple) | ~15 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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 winKeep
intlcurrent in asynchronous handlers.
_statusCheckand the claim effect close over theintlinstance from their render. If the user switches language while a request is in flight, these catch blocks can displayalert.unknow_errorin the old locale. Store the latestintlin 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
📒 Files selected for processing (11)
src/components/organisms/quickProfileModal/children/quickProfileContent.tsxsrc/components/postOptionsModal/container/postOptionsModal.tsxsrc/components/uploadsGalleryModal/container/uploadsGalleryModal.tsxsrc/containers/profileContainer.tsxsrc/containers/profileEditContainer.tsxsrc/containers/spinGameContainer.tssrc/containers/transferContainer.tssrc/screens/communityMembers/screen/communityMembersScreen.tsxsrc/screens/communitySettings/screen/communitySettingsScreen.tsxsrc/screens/transfer/screen/delegateScreen.tsxsrc/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.
There was a problem hiding this comment.
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
📒 Files selected for processing (11)
src/components/organisms/quickProfileModal/children/quickProfileContent.tsxsrc/components/postOptionsModal/container/postOptionsModal.tsxsrc/components/uploadsGalleryModal/container/uploadsGalleryModal.tsxsrc/containers/profileContainer.tsxsrc/containers/profileEditContainer.tsxsrc/containers/spinGameContainer.tssrc/containers/transferContainer.tssrc/screens/communityMembers/screen/communityMembersScreen.tsxsrc/screens/communitySettings/screen/communitySettingsScreen.tsxsrc/screens/transfer/screen/delegateScreen.tsxsrc/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
| captureException(err, (scope) => scope.setTag('context', 'spin-game-status')); | ||
| Alert.alert(get(err, 'message') || intl.formatMessage({ id: 'alert.unknow_error' })); |
There was a problem hiding this comment.
🎯 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.tsRepository: 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.
Closes #2684
Sixteen user-facing alerts across eleven files fell back to
error.toString()orString(err)for the message body, which shows raw stringified output when a throw carries nomessage(worst case[object Object]). All of them now fall back to the existingalert.unknow_errorlocale string ("An error occurred"), keeping the realerror.messagewhen present.useIntlfor its three alert sites; transferContainer's class site uses its injected intl.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
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
contexttag 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-batchand 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.