aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Kramkowski <tomasz@kramkow.ski>2023-03-24 19:31:31 +0000
committerTomasz Kramkowski <tomasz@kramkow.ski>2023-03-24 20:25:01 +0000
commit3a1374195b87356b7a50e6daa9782b6f62428c34 (patch)
tree9efcf85b9df0980dc025c8adb1640dd3559b96d6
parent1418e1b903a59a1b007ca5ac355ccfaebd9802c7 (diff)
downloadpaste-3a1374195b87356b7a50e6daa9782b6f62428c34.tar.gz
paste-3a1374195b87356b7a50e6daa9782b6f62428c34.tar.xz
paste-3a1374195b87356b7a50e6daa9782b6f62428c34.zip
catch_exceptions: set exc_info in response
-rw-r--r--paste/__init__.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/paste/__init__.py b/paste/__init__.py
index 85afc63..f8985eb 100644
--- a/paste/__init__.py
+++ b/paste/__init__.py
@@ -1,4 +1,5 @@
import binascii
+import sys
import traceback
from base64 import b64decode, b64encode
from collections.abc import Callable, Iterable
@@ -34,7 +35,9 @@ Response = Iterable[bytes]
DB_PATH = "paste.sqlite3"
-def simple_response(start_response: StartResponse, status: str) -> Response:
+def simple_response(
+ start_response: StartResponse, status: str, exc_info: Optional[tuple] = None
+) -> Response:
body = (status + "\n").encode()
start_response(
status,
@@ -42,6 +45,7 @@ def simple_response(start_response: StartResponse, status: str) -> Response:
("Content-Type", "text/plain"),
("Content-Length", str(len(body))),
],
+ exc_info,
)
return [body]
@@ -87,7 +91,9 @@ def catch_exceptions(app: App, environ: Env, start_response: StartResponse) -> R
return app(environ, start_response)
except Exception as e:
print("".join(traceback.format_exception(type(e), e, e.__traceback__)))
- return simple_response(start_response, "500 Internal Server Error")
+ return simple_response(
+ start_response, "500 Internal Server Error", sys.exc_info()
+ )
@middleware