tests/hgweberror.py
author Sean Farley <sean.michael.farley@gmail.com>
Mon, 15 Dec 2014 14:46:04 -0800
changeset 23774 b9537ee87961
parent 23409 dc4d2cd3aa3e
child 27299 74e6de99ce7f
permissions -rw-r--r--
namespaces: add method to return a list of nodes for a given name This is a helpful method that some extensions can make use of (e.g. for custom revsets); currently not used in core.

# A dummy extension that installs an hgweb command that throws an Exception.

from mercurial.hgweb import webcommands

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

    # Simulate an error after partial response.
    if 'partialresponse' in req.form:
        req.respond(200, 'text/plain')
        req.write('partial content\n')

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

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