Improve debug output

This commit is contained in:
Kumi 2022-04-19 13:32:38 +02:00
parent e286c0e023
commit 3593e5d95d
Signed by: kumi
GPG key ID: 5D1CE6AF1805ECA2

11
main.py
View file

@ -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 = "<h1>500 Internal Server Error</h1>\n"
if "debug" in req.args:
content += str(e)
content += traceback.format_exc().replace("\n", "<br />")
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 = "<h1>500 Internal Server Error</h1>\n"
if "debug" in req.args:
content += str(e).encode()
content += traceback.format_exc().replace("\n", "<br />")
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 = "<h1>500 Internal Server Error</h1>"
if "debug" in req.args:
content += repr(e)
content += traceback.format_exc().replace("\n", "<br />")
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 = "<h1>500 Internal Server Error</h1>\n"
if "debug" in req.args:
content += repr(e)
content += traceback.format_exc().replace("\n", "<br />")
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 = "<h1>500 Internal Server Error</h1>\n"
if "debug" in req.args:
content += str(e)
content += traceback.format_exc().replace("\n", "<br />")
return Response(HTTP500, HTML, content)
return Response(HTTP200, JSON if req.json else XML, content)