anonstream/anonstream/routes/error.py

17 行
557 B
Python
Raw 通常表示 履歴

2022-07-28 19:48:33 +09:00
from quart import current_app, render_template, request
2022-06-17 13:40:23 +09:00
from werkzeug.exceptions import default_exceptions
2022-07-28 19:48:33 +09:00
from anonstream.locale import get_locale_from
2022-06-17 13:40:23 +09:00
for error in default_exceptions:
async def handle(error):
2022-07-29 17:04:54 +09:00
if error.description == error.__class__.description:
error.description = None
2022-07-28 19:48:33 +09:00
return (
await render_template(
2022-07-29 17:04:54 +09:00
'error.html', error=error,
locale=get_locale_from(request)['http'],
2022-07-28 19:48:33 +09:00
), error.code
)
2022-06-17 13:40:23 +09:00
current_app.register_error_handler(error, handle)