1
0
mirror of https://github.com/krateng/maloja.git synced 2023-08-10 21:12:55 +03:00

Improved error page

This commit is contained in:
Krateng 2020-08-31 20:12:44 +02:00
parent d85d13ce5a
commit 363c431b93
3 changed files with 19 additions and 16 deletions

View File

@ -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

View File

@ -69,6 +69,7 @@
<tr> <td>artist</td> <td><i>Artist String</i></td> </tr>
<tr> <td>title</td> <td><i>Title String</i></td> </tr>
<tr> <td>key</td> <td><i>API Key</i></td> </tr>
<tr> <td>time</td> <td><i>UNIX timestamp - optional, defaults to time of request</i></td> </tr>
<tr> <td>seconds</td> <td><i>Duration of Scrobble - optional and currently not used</i></td> </tr>
</table>
<br/><br/>

View File

@ -8,12 +8,21 @@
<div style="background-image:url('/favicon.png')"></div>
</td>
<td class="text">
<h1>Error {{ errorcode }}</h1><br/>
<h1>{{ errordesc }}</h1><br/>
<p>{{ errordesc }}</p>
</td>
</tr>
</table>
{% if adminmode %}
You are only seeing this information because you are in admin mode:
<br/><br/>
<div style="white-space: pre-wrap; font-family: monospace;">{{ traceback }}</div>
{% else %}
A team of Korean schoolgirls with katanas has been dispatched to deal with this situation.
{% endif %}
{% endblock %}