Skip to content
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

Merged
merged 12 commits into from
Jun 14, 2024

Conversation

Yuki-YuXin
Copy link
Contributor

@Yuki-YuXin Yuki-YuXin commented Apr 16, 2024

Change summary:

Company PRs:
msal: AzureAD/microsoft-authentication-library-for-android#2080

Yuki-YuXin added a commit to AzureAD/microsoft-authentication-library-for-android that referenced this pull request May 14, 2024
### 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
@Yuki-YuXin Yuki-YuXin marked this pull request as ready for review May 14, 2024 14:42
val password = CharArray(binding.passwordText.length())
binding.passwordText.text?.getChars(0, binding.passwordText.length(), password, 0)

val actionResult: SignInResult
try {
Copy link
Collaborator

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?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Applies to multiple places.

Copy link
Contributor Author

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.

Copy link
Collaborator

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.

Copy link
Contributor Author

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)
Copy link
Collaborator

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.

Copy link
Contributor Author

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

@Yuki-YuXin Yuki-YuXin added the 5.3.1> Applied the PR when the new release after 5.3.1 has publiched label May 16, 2024
# Conflicts:
#	app/src/main/java/com/azuresamples/msalnativeauthandroidkotlinsampleapp/AccessApiFragment.kt
@Yuki-YuXin Yuki-YuXin merged commit 947ada2 into main Jun 14, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5.3.1> Applied the PR when the new release after 5.3.1 has publiched
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants