Skip to content

Commit 92459f8

Browse files
committed
fix: bug where response could be undefined
1 parent dee6f1f commit 92459f8

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

lib/http/intercepted_client.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,6 @@ class InterceptedClient extends BaseClient {
281281
/// Internal method that handles the actual request with retry logic
282282
Future<BaseResponse> _attemptRequestWithRetries(BaseRequest request,
283283
{bool isStream = false}) async {
284-
BaseResponse response;
285284
try {
286285
// Intercept request
287286
final interceptedRequest = await _interceptRequest(request);
@@ -358,7 +357,7 @@ class InterceptedClient extends BaseClient {
358357
stream = await completer.future;
359358
}
360359

361-
response = isStream ? stream : await Response.fromStream(stream);
360+
final response = isStream ? stream : await Response.fromStream(stream);
362361

363362
if (retryPolicy != null &&
364363
retryPolicy!.maxRetryAttempts > _retryCount &&
@@ -368,6 +367,8 @@ class InterceptedClient extends BaseClient {
368367
.delayRetryAttemptOnResponse(retryAttempt: _retryCount));
369368
return _attemptRequestWithRetries(request, isStream: isStream);
370369
}
370+
371+
return response;
371372
} on Exception catch (error) {
372373
if (retryPolicy != null &&
373374
retryPolicy!.maxRetryAttempts > _retryCount &&
@@ -380,8 +381,6 @@ class InterceptedClient extends BaseClient {
380381
rethrow;
381382
}
382383
}
383-
384-
return response;
385384
}
386385

387386
/// This internal function intercepts the request.

0 commit comments

Comments
 (0)