Debian Codegraph @

tests/hgweberror.py

raw
1 # A dummy extension that installs an hgweb command that throws an Exception.
2
3
4 from mercurial.hgweb import webcommands
5
6
7 def raiseerror(web):
8 '''Dummy web command that raises an uncaught Exception.'''
9
10 # Simulate an error after partial response.
11 if b'partialresponse' in web.req.qsparams:
12 web.res.status = b'200 Script output follows'
13 web.res.headers[b'Content-Type'] = b'text/plain'
14 web.res.setbodywillwrite()
15 list(web.res.sendresponse())
16 web.res.getbodyfile().write(b'partial content\n')
17
18 raise AttributeError('I am an uncaught error!')
19
20
21 def extsetup(ui):
22 setattr(webcommands, 'raiseerror', raiseerror)
23 webcommands.__all__.append('raiseerror')