python-jenkins-developers team mailing list archive
-
python-jenkins-developers team
-
Mailing list archive
-
Message #00163
[Bug 1246468] Re: Jenkins returning 404 cannot be distinguished
No, it does not; the exception raised isn't even raised for a 404 error.
I had to override jenkins_open() with the following code to get the
behavior I needed:
def jenkins_open(self, req):
try:
if self.auth:
req.add_header('Authorization', self.auth)
return urllib2.urlopen(req).read()
except urllib2.HTTPError, e:
# Jenkins's funky authentication means its nigh impossible to
# distinguish errors.
if e.code in [401, 403, 500]:
raise jenkins.JenkinsException(
'Error in request.' +
'Possibly authentication failed [%s]' % (e.code)
)
elif e.code == 404:
raise NotFoundException('Requested item could not be found')
# Log the error
self.ctxt.log.warn("HTTPError raised with code %d: %s" %
(e.code, e.msg))
--
You received this bug notification because you are a member of Python
Jenkins Developers, which is subscribed to Python Jenkins.
https://bugs.launchpad.net/bugs/1246468
Title:
Jenkins returning 404 cannot be distinguished
Status in Python API for Jenkins:
New
Bug description:
If a non-GET request is made for a resource which doesn't exist—such
as cancelling a non-existant queue item—no exception or error is
reported to the user. At the very least, a distinguishable error
should be raised. (Distinguishable in that it should not be
JenkinsException, although it should be a subclass of
JenkinsException).
To manage notifications about this bug go to:
https://bugs.launchpad.net/python-jenkins/+bug/1246468/+subscriptions
References