Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions packages/gotrue/lib/src/fetch.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,16 @@ class GotrueFetch {

AuthException _handleError(dynamic error) {
if (error is! Response) {
throw AuthRetryableFetchException();
throw AuthRetryableFetchException(message: error.toString());
}

// If the status is 500 or above, it's likely a server error,
// and can be retried.
if (error.statusCode >= 500) {
throw AuthRetryableFetchException();
throw AuthRetryableFetchException(
message: error.body,
statusCode: error.statusCode.toString(),
);
}

final dynamic data;
Expand Down Expand Up @@ -134,7 +137,7 @@ class GotrueFetch {
}
} catch (e) {
// fetch failed, likely due to a network or CORS error
throw AuthRetryableFetchException();
throw AuthRetryableFetchException(message: e.toString());
}

if (!isSuccessStatusCode(response.statusCode)) {
Expand Down
5 changes: 4 additions & 1 deletion packages/gotrue/lib/src/types/auth_exception.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ class AuthSessionMissingException extends AuthException {
}

class AuthRetryableFetchException extends AuthException {
AuthRetryableFetchException() : super('AuthRetryableFetchError');
AuthRetryableFetchException({
String message = 'AuthRetryableFetchException',
super.statusCode,
}) : super(message);
}

class AuthApiException extends AuthException {
Expand Down