Skip to content

Commit

Permalink
fix: Add error_code from url to AuthException (#968)
Browse files Browse the repository at this point in the history
fix: add error_code from url to AuthException
  • Loading branch information
Vinzent03 authored Jul 10, 2024
1 parent 4a87177 commit c741fe9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/gotrue/lib/src/gotrue_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -756,8 +756,9 @@ class GoTrueClient {
}

final errorDescription = url.queryParameters['error_description'];
final errorCode = url.queryParameters['error_code'];
if (errorDescription != null) {
throw AuthException(errorDescription);
throw AuthException(errorDescription, statusCode: errorCode);
}

if (_flowType == AuthFlowType.pkce) {
Expand Down
1 change: 1 addition & 0 deletions packages/gotrue/test/client_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ void main() {
fail('getSessionFromUrl did not throw exception');
} on AuthException catch (error) {
expect(error.message, errorMessage);
expect(error.statusCode, '401');
} catch (error) {
fail(
'getSessionFromUrl threw ${error.runtimeType} instead of AuthException');
Expand Down

0 comments on commit c741fe9

Please sign in to comment.