generated from kinde-oss/kinde-oss-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from kinde-oss/feature/sdk_reflect
+ Fix bug: can't load url with https
- Loading branch information
Showing
5 changed files
with
59 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
my_custom_templates/lib/src/handle_network_error_mixin.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import 'package:dio/dio.dart'; | ||
import 'package:kinde_flutter_sdk/src/kinde_error.dart'; | ||
|
||
mixin HandleNetworkMixin { | ||
Exception handleError(Exception error) { | ||
if (error is KindeError) { | ||
return error; | ||
} | ||
if (error is DioException) { | ||
DioException dioError = error; | ||
switch (dioError.type) { | ||
case DioExceptionType.cancel: | ||
case DioExceptionType.connectionTimeout: | ||
case DioExceptionType.receiveTimeout: | ||
case DioExceptionType.sendTimeout: | ||
case DioExceptionType.connectionError: | ||
case DioExceptionType.badCertificate: | ||
case DioExceptionType.unknown: | ||
if (dioError.error is KindeError) { | ||
return dioError.error as KindeError; | ||
} | ||
return KindeError(dioError.message ?? ""); | ||
case DioExceptionType.badResponse: | ||
if (dioError.requestOptions.path == "/oauth2/token") { | ||
return KindeError("Refresh token Expired"); | ||
} | ||
return KindeError(dioError.message ?? ""); | ||
} | ||
} else { | ||
return error; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters