From 3593e5d95d99eac07477dbdd774022b9e33e3227 Mon Sep 17 00:00:00 2001 From: Kumi Date: Tue, 19 Apr 2022 13:32:38 +0200 Subject: [PATCH] Improve debug output --- main.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index ffcd71e..3833c7a 100644 --- a/main.py +++ b/main.py @@ -2,6 +2,7 @@ import cgi import datetime import pytz import html +import traceback import workers.conn import workers.val @@ -78,7 +79,7 @@ def doConn(req): except Exception as e: content = "

500 Internal Server Error

\n" if "debug" in req.args: - content += str(e) + content += traceback.format_exc().replace("\n", "
") return Response(HTTP500, HTML, content) return Response(HTTP200, JSON if req.json else XML, content) @@ -104,7 +105,7 @@ def doVal(req): except Exception as e: content = "

500 Internal Server Error

\n" if "debug" in req.args: - content += str(e).encode() + content += traceback.format_exc().replace("\n", "
") return Response(HTTP500, HTML, content) return Response(HTTP200, JSON if req.json else XML, content) @@ -139,7 +140,7 @@ def doNearby(req): except Exception as e: content = "

500 Internal Server Error

" if "debug" in req.args: - content += repr(e) + content += traceback.format_exc().replace("\n", "
") return Response(HTTP500, HTML, content) return Response(HTTP200, JSON if req.json else XML, content) @@ -152,7 +153,7 @@ def doRadar(req): except Exception as e: content = "

500 Internal Server Error

\n" if "debug" in req.args: - content += repr(e) + content += traceback.format_exc().replace("\n", "
") return Response(HTTP500, HTML, content) return Response(HTTP200, JSON if req.json else XML, content) @@ -195,7 +196,7 @@ def doDepArr(req): except Exception as e: content = "

500 Internal Server Error

\n" if "debug" in req.args: - content += str(e) + content += traceback.format_exc().replace("\n", "
") return Response(HTTP500, HTML, content) return Response(HTTP200, JSON if req.json else XML, content)