fix(auth): handle 400 error during token refresh flow
This commit is contained in:
@@ -62,4 +62,18 @@ class CannotCalculateChangesMethodResponseException extends MethodLevelErrors {
|
||||
|
||||
class NoNetworkError extends RemoteException {
|
||||
const NoNetworkError() : super(message: RemoteException.noNetworkError);
|
||||
}
|
||||
|
||||
class RefreshTokenFailedException extends RemoteException {
|
||||
final int? statusCode;
|
||||
|
||||
RefreshTokenFailedException({
|
||||
super.message =
|
||||
'Refresh Token failed with 400 Bad Request. The session is invalid/revoked.',
|
||||
this.statusCode = 400,
|
||||
});
|
||||
|
||||
@override
|
||||
String toString() =>
|
||||
"RefreshTokenFailedException(status: $statusCode): $message";
|
||||
}
|
||||
@@ -37,6 +37,10 @@ class RemoteExceptionThrower extends ExceptionThrower {
|
||||
'RemoteExceptionThrower::throwException():type: ${error.type} | response: ${error.response} | error: ${error.error}',
|
||||
);
|
||||
|
||||
if (error.error is RefreshTokenFailedException) {
|
||||
throw RefreshTokenFailedException();
|
||||
}
|
||||
|
||||
final response = error.response;
|
||||
final statusCode = response?.statusCode;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user