From: Fredrik Tolf Date: Sat, 11 Jan 2014 04:46:06 +0000 (+0100) Subject: Added a function for handling errors coming externally. X-Git-Url: http://git.dolda2000.com/gitweb/?a=commitdiff_plain;h=d9ce65914152036450263d9b0103c0b81f35e052;p=wrw.git Added a function for handling errors coming externally. --- diff --git a/wrw/dispatch.py b/wrw/dispatch.py index f0326cb..666d7a7 100644 --- a/wrw/dispatch.py +++ b/wrw/dispatch.py @@ -55,3 +55,15 @@ def handleenv(env, startreq, handler): return proto.simpleerror(env, startreq, 400, "Bad Request", "Request must include Host header.") r = req.origrequest(env) return handle(r, startreq, handler) + +def exterror(env, startreq): + def handler(req): + import resp + code = 404 + if "Response-Code" in req.ihead: + try: + code = int(req.ihead["Response-Code"]) + except ValueError: + pass + raise resp.httperror(code) + return handleenv(env, startreq, handler)