From d9ce65914152036450263d9b0103c0b81f35e052 Mon Sep 17 00:00:00 2001 From: Fredrik Tolf Date: Sat, 11 Jan 2014 05:46:06 +0100 Subject: [PATCH] Added a function for handling errors coming externally. --- wrw/dispatch.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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) -- 2.11.0