-
Notifications
You must be signed in to change notification settings - Fork 0
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
Use ClientException instead of try catch block in sample app #24
Conversation
….message ?: error.errorMessage instead of error.toString() when displaying dialog.
### Changes summary: 1. Add GetAccountError and SignOutError error in Error.kt 2. Use try catch block with corresponding errors in interface methods. 3. Add testEmptyRequestParametersToGenericErrorNotThrownException() ### Company PRs: native sample app: Azure-Samples/ms-identity-ciam-native-auth-android-sample#24
...main/java/com/azuresamples/msalnativeauthandroidkotlinsampleapp/EmailSignInSignUpFragment.kt
Outdated
Show resolved
Hide resolved
val password = CharArray(binding.passwordText.length()) | ||
binding.passwordText.text?.getChars(0, binding.passwordText.length(), password, 0) | ||
|
||
val actionResult: SignInResult | ||
try { |
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.
Why do we still need this try? Also, a try without a catch?
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.
Applies to multiple places.
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.
I think it's because there is a try-finally block which has relation with the password security/privacy fix completed by Burak before.
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.
I get the point of the try-finally now, but I don't think we need a try at all now anymore. The SDK shouldn't throw an exception, so developers don't need to expect it.
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.
Removed try finally block
@@ -80,47 +81,46 @@ class AccessApiFragment : Fragment() { | |||
is GetAccountResult.NoAccountFound -> { | |||
displaySignedOutState() | |||
} | |||
is GetAccountError -> { | |||
displayDialog(getString(R.string.msal_exception_title), accountResult.exception?.message ?: accountResult.errorMessage) |
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.
For simplicity, let's just use accountResult.errorMessage
here. That's the ultimate error. For more details on the error, developers can look into the exception's message. What do you think?
If you agree, this comment applies to multiple places.
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.
Agreed. Will make the update
# Conflicts: # app/src/main/java/com/azuresamples/msalnativeauthandroidkotlinsampleapp/AccessApiFragment.kt
Change summary:
Company PRs:
msal: AzureAD/microsoft-authentication-library-for-android#2080