-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[local_auth] Adopt structured errors - platform interface #10023
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
base: main
Are you sure you want to change the base?
[local_auth] Adopt structured errors - platform interface #10023
Conversation
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
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.
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)'; |
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 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.
String toString() => 'LocalAuthException(code $code, $description, $details)'; | |
String toString() => 'LocalAuthException(code: ${code.name}, description: $description, details: $details)'; |
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 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
.
Platform interface portion of #9981
LocalAuthException
class for structured errors.AuthenticationOptions.useErrorDialogs
Part of:
local_auth
plugin flutter#113687useErrorDialogs
flutter#175125Pre-Review Checklist
[shared_preferences]
pubspec.yaml
with an appropriate new version according to the pub versioning philosophy, or I have commented below to indicate which version change exemption this PR falls under1.CHANGELOG.md
to add a description of the change, following repository CHANGELOG style, or I have commented below to indicate which CHANGELOG exemption this PR falls under1.///
).Footnotes
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