summaryrefslogtreecommitdiff
path: root/paste/errormiddleware.py
diff options
context:
space:
mode:
authorianb <devnull@localhost>2005-07-26 17:12:18 +0000
committerianb <devnull@localhost>2005-07-26 17:12:18 +0000
commit4a178bfb743266f15a9ed021985fe58f82c190c5 (patch)
tree0dd56dc2387aaa410ab3a9be5c36d6f2edf75507 /paste/errormiddleware.py
parent906b58b9d6bc62a02cc151423b6481ecf409d5ff (diff)
downloadpaste-4a178bfb743266f15a9ed021985fe58f82c190c5.tar.gz
Be more careful about whether headers were really sent, if an error occurs in the start_response call itself
Diffstat (limited to 'paste/errormiddleware.py')
-rw-r--r--paste/errormiddleware.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/paste/errormiddleware.py b/paste/errormiddleware.py
index cf8936b..83c4ba8 100644
--- a/paste/errormiddleware.py
+++ b/paste/errormiddleware.py
@@ -65,19 +65,24 @@ class ErrorMiddleware(object):
environ['paste.throw_errors'] = True
def detect_start_response(status, headers, exc_info=None):
- started.append(True)
- return start_response(status, headers, exc_info)
-
+ try:
+ return start_response(status, headers, exc_info)
+ except:
+ raise
+ else:
+ started.append(True)
try:
__traceback_supplement__ = Supplement, self, environ
app_iter = self.application(environ, detect_start_response)
return self.catching_iter(app_iter, environ)
except:
+ exc_info = sys.exc_info()
if not started:
start_response('500 Internal Server Error',
- [('content-type', 'text/html')])
+ [('content-type', 'text/html')],
+ exc_info)
# @@: it would be nice to deal with bad content types here
- response = self.exception_handler(sys.exc_info(), environ)
+ response = self.exception_handler(exc_info, environ)
return [response]
def catching_iter(self, app_iter, environ):