From 012f9593f057a197a20a270e1b70653865aff8c1 Mon Sep 17 00:00:00 2001 From: "R. David Murray" Date: Tue, 28 Feb 2017 16:32:48 -0500 Subject: [PATCH] Clearer error message for URL without a hostname. When I got the existing error message I had no idea what it meant. A little digging in the code reveals that the problem was I provided a URL that did not contain a hostname, so aiohttp was unable to parse the hostname out of that URL. Here is an alternate wording for the error message that I hope will lead the library user to understand what went wrong more quickly. --- aiohttp/client_reqrep.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/aiohttp/client_reqrep.py b/aiohttp/client_reqrep.py index 8f4fb91da6f..dc2c87a69da 100644 --- a/aiohttp/client_reqrep.py +++ b/aiohttp/client_reqrep.py @@ -116,7 +116,8 @@ def update_host(self, url): """Update destination host, port and connection type (ssl).""" # get host/port if not url.host: - raise ValueError('Host could not be detected.') + raise ValueError( + "Could not parse hostname from URL '{}'".format(self.url)) # basic auth info username, password = url.user, url.password