Fix unhandled exception in _HttpClientConnection after removing dynamic.

Change-Id: If838ce8f479986a488eb38b90b381c78956f5f6d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/265188
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
This commit is contained in:
Kallen Tu 2022-10-24 16:03:39 +00:00 committed by Commit Queue
parent 18acd0e44c
commit 3fe9cb8bae

View file

@ -2077,9 +2077,16 @@ class _HttpClientConnection {
_nextResponseCompleter = null;
}
}, onError: (dynamic error, StackTrace stackTrace) {
if (error is! HttpException) throw error; // Rethrow.
String message;
if (error is HttpException) {
message = error.message;
} else if (error is SocketException) {
message = error.message;
} else {
throw error;
}
_nextResponseCompleter?.completeError(
HttpException(error.message, uri: _currentUri), stackTrace);
HttpException(message, uri: _currentUri), stackTrace);
_nextResponseCompleter = null;
}, onDone: () {
_nextResponseCompleter?.completeError(HttpException(