File: hgweberror.py

package info (click to toggle)
mercurial 6.3.2-1%2Bdeb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 42,052 kB
  • sloc: python: 199,820; ansic: 46,300; tcl: 3,715; sh: 1,676; lisp: 1,483; cpp: 864; javascript: 649; makefile: 626; xml: 36; sql: 30
file content (23 lines) | stat: -rw-r--r-- 712 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# A dummy extension that installs an hgweb command that throws an Exception.


from mercurial.hgweb import webcommands


def raiseerror(web):
    '''Dummy web command that raises an uncaught Exception.'''

    # Simulate an error after partial response.
    if b'partialresponse' in web.req.qsparams:
        web.res.status = b'200 Script output follows'
        web.res.headers[b'Content-Type'] = b'text/plain'
        web.res.setbodywillwrite()
        list(web.res.sendresponse())
        web.res.getbodyfile().write(b'partial content\n')

    raise AttributeError('I am an uncaught error!')


def extsetup(ui):
    setattr(webcommands, 'raiseerror', raiseerror)
    webcommands.__all__.append(b'raiseerror')