Skip to content

Commit

Permalink
feat: remove python path prefix in traceback
Browse files Browse the repository at this point in the history
  • Loading branch information
queensferryme committed Sep 1, 2021
1 parent 36e8d7e commit ea8d923
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion rsserpent/main.py
@@ -1,4 +1,6 @@
import os
import re
import sys
import traceback
from pathlib import Path

Expand All @@ -20,12 +22,15 @@

async def exception_handler(request: Request, exception: Exception) -> TemplateResponse:
"""Return an HTML web page for displaying the current exception."""
tb = traceback.format_exc()
for path in sys.path:
tb, _ = re.subn(fr'(?<=File "){re.escape(path)}[/\\]', "", tb)
return templates.TemplateResponse(
"exception.html.jinja",
{
"exception": exception,
"request": request,
"traceback": traceback.format_exc(),
"traceback": tb,
},
)

Expand Down
2 changes: 1 addition & 1 deletion rsserpent/templates/exception.html.jinja
Expand Up @@ -47,7 +47,7 @@
padding: .3em 0;
}
</style>
<title>RSSerpent Crashed!</title>
<title>RSSerpent Crashed (T鈱揟)</title>
</head>
<body>
<main>
Expand Down

0 comments on commit ea8d923

Please sign in to comment.