fix(auth): handle 400 error during token refresh flow

This commit is contained in:
dab246
2026-02-05 15:14:19 +07:00
committed by Dat H. Pham
parent eb1805d010
commit ada44dd5d0
4 changed files with 72 additions and 16 deletions
+14
View File
@@ -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;