You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -273,13 +287,56 @@ class ExpiredTokenRetryPolicy extends RetryPolicy {
273
287
274
288
You can also set the maximum amount of retry attempts with `maxRetryAttempts` property or override the `shouldAttemptRetryOnException` if you want to retry the request after it failed with an exception.
275
289
290
+
### RetryPolicy Interface
291
+
292
+
The `RetryPolicy` abstract class provides the following methods that you can override:
293
+
294
+
-**`shouldAttemptRetryOnException(Exception reason, BaseRequest request)`**: Called when an exception occurs during the request. Return `true` to retry, `false` to fail immediately.
295
+
-**`shouldAttemptRetryOnResponse(BaseResponse response)`**: Called after receiving a response. Return `true` to retry, `false` to accept the response.
296
+
-**`maxRetryAttempts`**: The maximum number of retry attempts (default: 1).
297
+
-**`delayRetryAttemptOnException({required int retryAttempt})`**: Delay before retrying after an exception (default: no delay).
298
+
-**`delayRetryAttemptOnResponse({required int retryAttempt})`**: Delay before retrying after a response (default: no delay).
299
+
300
+
### Using Retry Policies
301
+
302
+
To use a retry policy, pass it to the `InterceptedClient` or `InterceptedHttp`:
303
+
304
+
```dart
305
+
final client = InterceptedClient.build(
306
+
interceptors: [WeatherApiInterceptor()],
307
+
retryPolicy: ExpiredTokenRetryPolicy(),
308
+
);
309
+
```
310
+
276
311
Sometimes it is helpful to have a cool-down phase between multiple requests. This delay could for example also differ between the first and the second retry attempt as shown in the following example.
277
312
278
313
```dart
279
314
class ExpiredTokenRetryPolicy extends RetryPolicy {
0 commit comments