diff options
-rwxr-xr-x | bottle.py | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -1025,6 +1025,7 @@ class Bottle(object): stacktrace = format_exc() environ['wsgi.errors'].write(stacktrace) environ['wsgi.errors'].flush() + environ['bottle.exc_info'] = sys.exc_info() out = HTTPError(500, "Internal Server Error", E, stacktrace) out.apply(response) @@ -1105,6 +1106,7 @@ class Bottle(object): def wsgi(self, environ, start_response): """ The bottle WSGI-interface. """ + provided_exc_info = False try: out = self._cast(self._handle(environ)) # rfc2616 section 4.3 @@ -1112,11 +1114,16 @@ class Bottle(object): or environ['REQUEST_METHOD'] == 'HEAD': if hasattr(out, 'close'): out.close() out = [] - start_response(response._wsgi_status_line(), response.headerlist) + exc_info = environ.get('bottle.exc_info') + if exc_info is not None: + del environ['bottle.exc_info'] + provided_exc_info = True + start_response(response._wsgi_status_line(), response.headerlist, exc_info) return out except (KeyboardInterrupt, SystemExit, MemoryError): raise except Exception as E: + if provided_exc_info: raise if not self.catchall: raise err = '<h1>Critical error while processing request: %s</h1>' \ % html_escape(environ.get('PATH_INFO', '/')) |