From c741fe9d7458e7aaadf779a8d8f14636b4aeb136 Mon Sep 17 00:00:00 2001 From: Vinzent Date: Wed, 10 Jul 2024 11:55:07 +0200 Subject: [PATCH] fix: Add error_code from url to AuthException (#968) fix: add error_code from url to AuthException --- packages/gotrue/lib/src/gotrue_client.dart | 3 ++- packages/gotrue/test/client_test.dart | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/gotrue/lib/src/gotrue_client.dart b/packages/gotrue/lib/src/gotrue_client.dart index 7f50b152..76e774dd 100644 --- a/packages/gotrue/lib/src/gotrue_client.dart +++ b/packages/gotrue/lib/src/gotrue_client.dart @@ -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) { diff --git a/packages/gotrue/test/client_test.dart b/packages/gotrue/test/client_test.dart index 35fae8a0..79951b76 100644 --- a/packages/gotrue/test/client_test.dart +++ b/packages/gotrue/test/client_test.dart @@ -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');