diff --git a/jenkins/__init__.py b/jenkins/__init__.py index ac43cdf..c7ad650 100644 --- a/jenkins/__init__.py +++ b/jenkins/__init__.py @@ -235,9 +235,14 @@ class Jenkins(object): # Jenkins's funky authentication means its nigh impossible to # distinguish errors. if e.code in [401, 403, 500]: + # six.moves.urllib.error.HTTPError provides a 'reason' + # attribute for all python version except for ver 2.6 + # Falling back to HTTPError.msg since it contains the + # same info as reason raise JenkinsException( - 'Error in request.' + - 'Possibly authentication failed [%s]' % (e.code) + 'Error in request. ' + + 'Possibly authentication failed [%s]: %s' % ( + e.code, e.msg) ) # right now I'm getting 302 infinites on a successful delete diff --git a/tests/test_jenkins.py b/tests/test_jenkins.py index e054387..c28b8f4 100644 --- a/tests/test_jenkins.py +++ b/tests/test_jenkins.py @@ -156,7 +156,8 @@ class JenkinsTest(unittest.TestCase): j.jenkins_open(request, add_crumb=False) self.assertEqual( str(context_manager.exception), - 'Error in request.Possibly authentication failed [401]') + 'Error in request. Possibly authentication failed [401]: ' + 'basic auth failed') self.assertEqual( jenkins_mock.call_args[0][0].get_full_url(), 'http://example.com/job/TestJob')