Throw more specific exception for a request on a close IOClient (#584)
Closes #581
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ab8a022..08a3a0b 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 5ee66db..85d3681 100644
--- a/lib/src/io_client.dart
+++ b/lib/src/io_client.dart
@@ -24,6 +24,11 @@
/// Sends an HTTP request and asynchronously returns the response.
@override
Future<IOStreamedResponse> send(BaseRequest request) async {
+ if (_inner == null) {
+ throw ClientException(
+ 'HTTP request failed. Client is already closed.', request.url);
+ }
+
var stream = request.finalize();
try {