util:http: special handling for HTTP_USER_ERROR in get_post_url().
authorW. Trevor King <wking@tremily.us>
Mon, 29 Oct 2012 00:08:30 +0000 (20:08 -0400)
committerW. Trevor King <wking@tremily.us>
Mon, 29 Oct 2012 00:08:30 +0000 (20:08 -0400)
libbe/util/http.py

index b3070926b03fdb967ae0bf1b22b99280306f392f..a1ab06a4e4ea2597ab797f55f3696c79959f2a5d 100644 (file)
@@ -105,10 +105,11 @@ def get_post_url(url, get=True, data=None, data_dict=None, headers=[],
     try:
         response = urllib2.urlopen(req)
     except urllib2.HTTPError, e:
-        lines = [
-            'We failed to connect to the server (HTTPError).',
-            'URL: {}'.format(url),
-            ]
+        if e.code == HTTP_USER_ERROR:
+            lines = ['The server reported a user error (HTTPError)']
+        else:
+            lines = ['The server reported an error (HTTPError)']
+        lines.append('URL: {}'.format(url))
         if hasattr(e, 'reason'):
             lines.append('Reason: {}'.format(e.reason))
         lines.append('Error code: {}'.format(e.code))