From f25bfa6ad16751af7df41df06d9a161eb54bcc84 Mon Sep 17 00:00:00 2001 From: Juergen Weigert Date: Sun, 7 Mar 2010 21:56:29 +0100 Subject: [PATCH] made URLError readable, instead of a bogus stack-trace. added full_url, to even give a hint about the cause. --- osc/babysitter.py | 2 +- osc/oscssl.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/osc/babysitter.py b/osc/babysitter.py index 2a0ec41a..024392b8 100644 --- a/osc/babysitter.py +++ b/osc/babysitter.py @@ -108,7 +108,7 @@ def run(prg): return 1 except URLError, e: - print >>sys.stderr, 'Failed to reach a server:', e.reason + print >>sys.stderr, 'Failed to reach a server:\n', e.reason return 1 except (oscerr.ConfigError, oscerr.NoConfigfile), e: diff --git a/osc/oscssl.py b/osc/oscssl.py index bc3a5b96..3dc47f2a 100644 --- a/osc/oscssl.py +++ b/osc/oscssl.py @@ -172,7 +172,7 @@ class myHTTPSHandler(M2Crypto.m2urllib2.HTTPSHandler): def https_open(self, req): host = req.get_host() if not host: - raise URLError('no host given') + raise M2Crypto.m2urllib2.URLError('no host given: ' + req.get_full_url()) # Our change: Check to see if we're using a proxy. # Then create an appropriate ssl-aware connection. @@ -199,7 +199,8 @@ class myHTTPSHandler(M2Crypto.m2urllib2.HTTPSHandler): h.request(req.get_method(), req.get_full_url(), req.data, headers) r = h.getresponse() except socket.error, err: # XXX what error? - raise URLError(err) + err.filename = full_url + raise M2Crypto.m2urllib2.URLError(err) # Pick apart the HTTPResponse object to get the addinfourl # object initialized properly.