Flutter Web: Generic ClientException
on 401/403 Prevents Effective Retry Logic in shouldAttemptRetryOnResponse
#152
Labels
bug
Something isn't working
GitHub Issue: Generic ClientException on 401/403 Prevents Effective Retry Logic
When using
http_interceptor
with a customRetryPolicy
, the retry logic does not work correctly for 401 and 403 HTTP status codes. The issue arises because the client throws a genericClientException
for these responses instead of allowing the response object to flow through. This causes the logic to be handled byshouldAttemptRetryOnException
rather thanshouldAttemptRetryOnResponse
.The
ClientException
provides no meaningful details about the HTTP response (e.g., status code or headers), making it impossible to determine if the request should be retried. This severely limits the ability to implement token refresh or retry policies based on specific HTTP status codes.Steps to Reproduce:
RetryPolicy
class and implementshouldAttemptRetryOnResponse
to handle 401/403 responses._attemptRequest
throws aClientException
instead of passing the response toshouldAttemptRetryOnResponse
.shouldAttemptRetryOnException
, theException
object lacks sufficient details to identify the HTTP status code.Expected Behavior:
The library should allow responses with 401 and 403 status codes to be passed to
shouldAttemptRetryOnResponse
for appropriate handling.Actual Behavior:
The library throws a generic
ClientException
with no meaningful information, forcing retry logic to rely on incomplete data inshouldAttemptRetryOnException
.Example:
Environment:
http_interceptor
version: 2.0.0Additional Context:
The generic
ClientException
in this case provides an error like "XMLHttpRequest error," which is not useful for making retry decisions.The text was updated successfully, but these errors were encountered: