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

Improved error handling and output

This commit is contained in:
krateng 2021-12-09 06:26:06 +01:00
parent 83063ba943
commit e901ca719f
2 changed files with 16 additions and 14 deletions

View File

@ -117,18 +117,20 @@ def clean_html(inp):
@webserver.error(503) @webserver.error(503)
@webserver.error(505) @webserver.error(505)
def customerror(error): def customerror(error):
errorcode = error.status_code error_code = error.status_code
errordesc = error.status error_desc = error.status
traceback = error.traceback or error.body traceback = error.traceback
body = error.body or ""
traceback = traceback.strip() if traceback is not None else "No Traceback" traceback = traceback.strip() if traceback is not None else "No Traceback"
adminmode = request.cookies.get("adminmode") == "true" and auth.check(request) adminmode = request.cookies.get("adminmode") == "true" and auth.check(request)
template = jinja_environment.get_template('error.jinja') template = jinja_environment.get_template('error.jinja')
return template.render( return template.render(
errorcode=errorcode, error_code=error_code,
errordesc=errordesc, error_desc=error_desc,
traceback=traceback, traceback=traceback,
adminmode=adminmode, error_full_desc=body,
adminmode=adminmode,
) )
@ -345,14 +347,13 @@ def unregister_temp_endpoint():
def wait_for_db(): def wait_for_db():
register_endpoints_web_static() register_endpoints_web_static()
register_temp_endpoint()
database.start_db()
register_endpoints_api() register_endpoints_api()
register_endpoints_web_dynamic() register_endpoints_web_dynamic()
unregister_temp_endpoint() database.start_db()
def run_server(): def run_server():

View File

@ -8,7 +8,8 @@
<div style="background-image:url('/favicon.png')"></div> <div style="background-image:url('/favicon.png')"></div>
</td> </td>
<td class="text"> <td class="text">
<h1>{{ errordesc }}</h1><br/> <h1>{{ error_desc }}</h1><br/>
{{ error_full_desc }}
</td> </td>
</tr> </tr>
@ -23,7 +24,7 @@
{{ traceback }} {{ traceback }}
{%- endautoescape %}</div> {%- endautoescape %}</div>
{% else %} {% else %}
A team of Korean schoolgirls with katanas has been dispatched to deal with this situation. Kazuma, Aqua, Darkness and Megumin have been dispatched to deal with this situation.
{% endif %} {% endif %}