-
-
Notifications
You must be signed in to change notification settings - Fork 45
correct error handling #3182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
correct error handling #3182
Conversation
📝 WalkthroughWalkthroughThe changes address two issues in the codebase. First, in the phone verification fragment, operator precedence in a string concatenation with a ternary conditional was corrected by adding parentheses, ensuring the intended error message is displayed. Second, in the biometrics helper utility, a method was updated to actively throw an Sequence Diagram(s)sequenceDiagram
participant Caller
participant BiometricsHelper
Caller->>BiometricsHelper: crashWithInvalidSecurityTypeException(context)
BiometricsHelper->>Caller: Throws IllegalStateException with localized message
sequenceDiagram
participant User
participant PersonalIdPhoneVerificationFragment
User->>PersonalIdPhoneVerificationFragment: Triggers OTP verification failure
PersonalIdPhoneVerificationFragment->>PersonalIdPhoneVerificationFragment: onFailure(errorMessage)
PersonalIdPhoneVerificationFragment->>PersonalIdPhoneVerificationFragment: Display error message (correct precedence)
✨ Finishing Touches
🧪 Generate Unit Tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
app/src/org/commcare/utils/BiometricsHelper.java (1)
243-245: Throwing the exception is correct, but consider removing the now-unreachable fallbackyield.
crashWithInvalidSecurityTypeException()now reliably throwsIllegalStateException, so any code that follows the call in thedefaultarm of the switch (lines 236-239) is never reached at runtime. Keeping theyield(and the surrounding string construction) can be misleading and may be flagged by static-analysis tools as dead code.-default -> { - crashWithInvalidSecurityTypeException(activity, requiredLock); - yield activity.getString(R.string.configuration_process_failed_server_msg, requiredLock); -} +default -> crashWithInvalidSecurityTypeException(activity, requiredLock);This preserves the compile-time requirement that every arm produces a value (because the method never returns) while removing unreachable code.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
app/src/org/commcare/fragments/personalId/PersonalIdPhoneVerificationFragment.java(1 hunks)app/src/org/commcare/utils/BiometricsHelper.java(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
app/src/org/commcare/utils/BiometricsHelper.java (1)
app/src/org/commcare/android/database/connect/models/PersonalIdSessionData.kt (1)
requiredLock(9-38)
🔇 Additional comments (1)
app/src/org/commcare/fragments/personalId/PersonalIdPhoneVerificationFragment.java (1)
113-115: Precedence bug fixed — good catch!Parenthesising the ternary guarantees the intended concatenation order and prevents messages like
"Some stringfalse"from leaking into production.
55e74dd to
70068c5
Compare
| default -> { | ||
| crashWithInvalidSecurityTypeException(activity, requiredLock); | ||
| yield activity.getString(R.string.configuration_process_failed_server_msg, requiredLock); | ||
| yield null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shubham1g5 I think instead of returning null, returning string would be better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it doesn't matter as we will never reach this line with the call above throwing an exception, it's just required to satisfy the compiler.
|
@damagatchi retest this please |
Product Description
Fixes some error handling code.
Labels and Review