diff options
author | ianb <devnull@localhost> | 2007-04-03 19:42:06 +0000 |
---|---|---|
committer | ianb <devnull@localhost> | 2007-04-03 19:42:06 +0000 |
commit | 055d0978635773630f1980f7201b033002049427 (patch) | |
tree | 1bdb98e7fa3cebc8945978903d879f00ef3c6c94 /paste/exceptions | |
parent | 0a91d7bab1d2b94a422c77cf0294b453090d3b4a (diff) | |
download | paste-055d0978635773630f1980f7201b033002049427.tar.gz |
Always (re)call start_response when an exception happens
Diffstat (limited to 'paste/exceptions')
-rw-r--r-- | paste/exceptions/errormiddleware.py | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/paste/exceptions/errormiddleware.py b/paste/exceptions/errormiddleware.py index def30f9..0436c28 100644 --- a/paste/exceptions/errormiddleware.py +++ b/paste/exceptions/errormiddleware.py @@ -126,31 +126,23 @@ class ErrorMiddleware(object): # We want to be careful about not sending headers twice, # and the content type that the app has committed to (if there # is an exception in the iterator body of the response) - started = [] if environ.get('paste.throw_errors'): return self.application(environ, start_response) 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: __traceback_supplement__ = Supplement, self, environ - app_iter = self.application(environ, detect_start_response) + app_iter = self.application(environ, start_response) return self.make_catching_iter(app_iter, environ) except: exc_info = sys.exc_info() try: - if not started: - # Only delegate expected exceptions if the response - # has not been started. - for expect in environ.get('paste.expected_exceptions', []): - if isinstance(exc_info[1], expect): - raise - start_response('500 Internal Server Error', - [('content-type', 'text/html')], - exc_info) + for expect in environ.get('paste.expected_exceptions', []): + if isinstance(exc_info[1], expect): + raise + start_response('500 Internal Server Error', + [('content-type', 'text/html')], + exc_info) # @@: it would be nice to deal with bad content types here response = self.exception_handler(exc_info, environ) return [response] |