diff --git a/maloja/server.py b/maloja/server.py index 32b2996..563756e 100755 --- a/maloja/server.py +++ b/maloja/server.py @@ -83,17 +83,6 @@ def mainpage(): response = static_html("start") return response -errortypes = { - 400: "Bad Request", - 403: "Forbidden", - 404: "Not Found", - 405: "Method Not Allowed", - 408: "Request Timeout", - 418: "I'm a teapot", - 500: "Internal Server Error", - 505: "HTTP Version Not Supported" -} - @webserver.error(400) @webserver.error(403) @webserver.error(404) @@ -102,10 +91,14 @@ errortypes = { @webserver.error(500) @webserver.error(505) def customerror(error): - code = int(str(error).split(",")[0][1:]) + errorcode = error.status_code + errordesc = error.status + traceback = error.traceback.strip() + + adminmode = request.cookies.get("adminmode") == "true" and auth.check(request) template = jinja_environment.get_template('error.jinja') - res = template.render(errorcode=code,errordesc=errortypes[code]) + res = template.render(errorcode=errorcode,errordesc=errordesc,traceback=traceback,adminmode=adminmode) return res diff --git a/maloja/web/jinja/admin_setup.jinja b/maloja/web/jinja/admin_setup.jinja index b7c46c9..7c7aced 100644 --- a/maloja/web/jinja/admin_setup.jinja +++ b/maloja/web/jinja/admin_setup.jinja @@ -69,6 +69,7 @@ artist Artist String title Title String key API Key + time UNIX timestamp - optional, defaults to time of request seconds Duration of Scrobble - optional and currently not used

diff --git a/maloja/web/jinja/error.jinja b/maloja/web/jinja/error.jinja index a252d23..d143383 100644 --- a/maloja/web/jinja/error.jinja +++ b/maloja/web/jinja/error.jinja @@ -8,12 +8,21 @@
-

Error {{ errorcode }}


+

{{ errordesc }}


- -

{{ errordesc }}

+ + + {% if adminmode %} + You are only seeing this information because you are in admin mode: +

+
{{ traceback }}
+ {% else %} + A team of Korean schoolgirls with katanas has been dispatched to deal with this situation. + {% endif %} + + {% endblock %}