From f93c76fabdb03963303762e3fe16cbdf60799cff Mon Sep 17 00:00:00 2001 From: Guy Luz Date: Fri, 25 Jun 2021 01:08:40 +0300 Subject: [PATCH] Throw more specific exception for a request on a close IOClient (#584) Closes #581 --- CHANGELOG.md | 2 ++ lib/src/io_client.dart | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab8a02203c..08a3a0b011 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ## 0.13.4-dev +* Throw a more useful error when a client is used after it has been closed. + ## 0.13.3 * Validate that the `method` parameter of BaseRequest is a valid "token". diff --git a/lib/src/io_client.dart b/lib/src/io_client.dart index 5ee66db0f8..85d3681861 100644 --- a/lib/src/io_client.dart +++ b/lib/src/io_client.dart @@ -24,6 +24,11 @@ class IOClient extends BaseClient { /// Sends an HTTP request and asynchronously returns the response. @override Future send(BaseRequest request) async { + if (_inner == null) { + throw ClientException( + 'HTTP request failed. Client is already closed.', request.url); + } + var stream = request.finalize(); try {