Skip to content

Commit 35e4e47

Browse files
committed
fix: add error_code from url to AuthException
1 parent c65cb61 commit 35e4e47

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

packages/gotrue/lib/src/gotrue_client.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -756,8 +756,9 @@ class GoTrueClient {
756756
}
757757

758758
final errorDescription = url.queryParameters['error_description'];
759+
final errorCode = url.queryParameters['error_code'];
759760
if (errorDescription != null) {
760-
throw AuthException(errorDescription);
761+
throw AuthException(errorDescription, statusCode: errorCode);
761762
}
762763

763764
if (_flowType == AuthFlowType.pkce) {

packages/gotrue/test/client_test.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ void main() {
137137
fail('getSessionFromUrl did not throw exception');
138138
} on AuthException catch (error) {
139139
expect(error.message, errorMessage);
140+
expect(error.statusCode, '401');
140141
} catch (error) {
141142
fail(
142143
'getSessionFromUrl threw ${error.runtimeType} instead of AuthException');

0 commit comments

Comments
 (0)