[flutter_appauth] Expose native exception type and code to the Flutter code
An implementation for the issue https://github.com/MaikuB/flutter_appauth/issues/394
It employs a new code format: <existing code>:<domain/type>:<code>
This might need to be considered as Breaking Changes, as it breaks the code that checks code right now. But it can be easily fixed:
For existing code:
try {
// calling appauth
} on PlatformException catch(ex) {
if (ex.code == "authorize_and_exchange_code_failed") {
// handle error
}
}
It can be upgraded as
try {
// calling appauth
} on PlatformException catch(ex) {
if (ex.code.startsWith("authorize_and_exchange_code_failed:")) {
// handle error
}
}
For user cancelled the webview for auth, the error could be
- iOS:
authorize_and_exchange_code_failed:org.openid.appauth.general:-3 - Android:
authorize_and_exchange_code_failed:GENERAL_ERROR:1
Hey @timnew, would it be possible to change this PR so the there's now a new Exception class that gets thrown by the plugin? The thinking behind this is to avoid having consumers of the plugin fiddling with the string and have the native error code by the native SDKs be behind a separate property. This would also be in-line with what I read recently in https://github.com/flutter/flutter/wiki/Contributing-to-Plugins-and-Packages#platform-exception-handling that IMO makes sense to adopt in this situation. This would look something like defining a new class in the platform interface package for the exception whose structure is similar to that defined in https://api.flutter.dev/flutter/services/PlatformException-class.html but have a nullable error property named something like nativeAppAuthSDKErrorCode whose purpose is to hold the error codes thrown by the native AppAuth Android/iOS SDKs. Let me know what you think
@MaikuB I'll try to do it asap! Got a bit snowed by the daily work
@timnew any updates on this MR? Could you look into it?
When is this going to be completed/merged? Its been close to 4 months since there were some changes requested.
https://docs.github.com/articles/what-are-the-different-access-permissions
Reminder that a good number of people working on open source software do so via their spare time. If you have need for something then you can look at carrying on the work yourself via your own fork
Closing this in favour of #509 that has been merged in