6 class restart(Exception):
19 def defaulterror(req, excinfo):
21 traceback.print_exception(*excinfo)
22 raise resp.httperror(500)
24 def wraphandler(handler, excinfo):
26 return handler(req, excinfo)
27 wrapped.__wrapped__ = handler
30 errorhandler = env.var(defaulterror)
32 def handle(req, startreq, handler):
45 handler = wraphandler(eh, sys.exc_info())
52 def handleenv(env, startreq, handler):
53 if not "HTTP_HOST" in env:
54 return proto.simpleerror(env, startreq, 400, "Bad Request", "Request must include Host header.")
55 r = req.origrequest(env)
56 return handle(r, startreq, handler)