Show More
@@ -14,11 +14,10 b' import os' | |||||
14 | from .common import ( |
|
14 | from .common import ( | |
15 | ErrorResponse, |
|
15 | ErrorResponse, | |
16 | HTTP_BAD_REQUEST, |
|
16 | HTTP_BAD_REQUEST, | |
17 | HTTP_NOT_FOUND, |
|
|||
18 | HTTP_OK, |
|
17 | HTTP_OK, | |
19 | HTTP_SERVER_ERROR, |
|
|||
20 | cspvalues, |
|
18 | cspvalues, | |
21 | permhooks, |
|
19 | permhooks, | |
|
20 | statusmessage, | |||
22 | ) |
|
21 | ) | |
23 |
|
22 | |||
24 | from .. import ( |
|
23 | from .. import ( | |
@@ -417,18 +416,25 b' class hgweb(object):' | |||||
417 | return content |
|
416 | return content | |
418 |
|
417 | |||
419 | except (error.LookupError, error.RepoLookupError) as err: |
|
418 | except (error.LookupError, error.RepoLookupError) as err: | |
420 | wsgireq.respond(HTTP_NOT_FOUND, ctype) |
|
|||
421 | msg = pycompat.bytestr(err) |
|
419 | msg = pycompat.bytestr(err) | |
422 | if (util.safehasattr(err, 'name') and |
|
420 | if (util.safehasattr(err, 'name') and | |
423 | not isinstance(err, error.ManifestLookupError)): |
|
421 | not isinstance(err, error.ManifestLookupError)): | |
424 | msg = 'revision not found: %s' % err.name |
|
422 | msg = 'revision not found: %s' % err.name | |
425 | return tmpl('error', error=msg) |
|
423 | ||
426 | except (error.RepoError, error.RevlogError) as inst: |
|
424 | res.status = '404 Not Found' | |
427 | wsgireq.respond(HTTP_SERVER_ERROR, ctype) |
|
425 | res.headers['Content-Type'] = ctype | |
428 |
re |
|
426 | res.setbodygen(tmpl('error', error=msg)) | |
429 | except ErrorResponse as inst: |
|
427 | return res.sendresponse() | |
430 | wsgireq.respond(inst, ctype) |
|
428 | except (error.RepoError, error.RevlogError) as e: | |
431 | return tmpl('error', error=pycompat.bytestr(inst)) |
|
429 | res.status = '500 Internal Server Error' | |
|
430 | res.headers['Content-Type'] = ctype | |||
|
431 | res.setbodygen(tmpl('error', error=pycompat.bytestr(e))) | |||
|
432 | return res.sendresponse() | |||
|
433 | except ErrorResponse as e: | |||
|
434 | res.status = statusmessage(e.code, pycompat.bytestr(e)) | |||
|
435 | res.headers['Content-Type'] = ctype | |||
|
436 | res.setbodygen(tmpl('error', error=pycompat.bytestr(e))) | |||
|
437 | return res.sendresponse() | |||
432 |
|
438 | |||
433 | def check_perm(self, rctx, req, op): |
|
439 | def check_perm(self, rctx, req, op): | |
434 | for permhook in permhooks: |
|
440 | for permhook in permhooks: |
General Comments 0
You need to be logged in to leave comments.
Login now