Skip to content

Conversation

stuartmorgan-g
Copy link
Collaborator

Platform interface portion of #9981

  • Adds the new LocalAuthException class for structured errors.
  • Deprecates AuthenticationOptions.useErrorDialogs

Part of:

Pre-Review Checklist

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. 2 3

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces structured error handling to the local_auth platform interface by adding a new LocalAuthException class and a LocalAuthExceptionCode enum. This is a valuable improvement as it allows for more granular and consistent error handling across platforms. The contract of the authenticate method has been clarified in the documentation to reflect these changes. Additionally, the useErrorDialogs option in AuthenticationOptions is now deprecated. The changes are well-structured and include necessary updates to tests, the changelog, and pubspec. I have one minor suggestion to enhance the new exception class for better debuggability.

final Object? details;

@override
String toString() => 'LocalAuthException(code $code, $description, $details)';

Choose a reason for hiding this comment

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

medium

For better readability and consistency with Dart conventions, it's good practice for toString() to return a string that resembles a constructor call with named parameters. Using code.name for the enum value will also produce a cleaner output, which is helpful for debugging.

Suggested change
String toString() => 'LocalAuthException(code $code, $description, $details)';
String toString() => 'LocalAuthException(code: ${code.name}, description: $description, details: $details)';

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I adjusted to follow the Flutter style for toString, using objectRuntimeType, which I had forgotten to do. Flutter style doesn't do named arguments for everything, but I did add the .name for code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant