Skip to content

Commit e1294e1

Browse files
Nicer formatting of fallback, returns 206 (partial) instead of 500
1 parent c2e09b8 commit e1294e1

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/labthings_fastapi/server/fallback.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,18 @@ def __init__(self, *args, **kwargs):
3838
<pre>{{traceback}}</pre>
3939
{{logginginfo}}
4040
</body>
41+
<style>
42+
pre {
43+
white-space: pre-wrap;
44+
overflow-wrap: anywhere;
45+
}
4146
</html>
4247
"""
4348

4449

4550
@app.get("/")
4651
async def root():
47-
error_message = f"{app.labthings_error!r}"
52+
error_message = f"{app.labthings_error}"
4853
# use traceback.format_exception to get full traceback as list
4954
# this ends in newlines, but needs joining to be a single string
5055
error_w_trace = "".join(format_exception(app.labthings_error))
@@ -65,7 +70,7 @@ async def root():
6570
logging_info = f" <p>Logging info</p>\n <pre>{app.log_history}</pre>"
6671

6772
content = content.replace("{{logginginfo}}", logging_info)
68-
return HTMLResponse(content=content, status_code=500)
73+
return HTMLResponse(content=content, status_code=206)
6974

7075

7176
@app.get("/{path:path}")

0 commit comments

Comments
 (0)