Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/howitz/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
from howitz.config.utils import load_config
from howitz.config.zino1 import make_zino1_config
from howitz.config.howitz import make_howitz_config
from howitz.error_handlers import handle_generic_exception, handle_generic_http_exception, handle_400, handle_404, handle_403, handle_lost_connection
from howitz.error_handlers import handle_generic_exception, handle_generic_http_exception, handle_400, handle_404, \
handle_403, handle_lost_connection, handle_timeout
from howitz.users.db import UserDB
from howitz.users.commands import user_cli
from zinolib.controllers.zino1 import Zino1EventManager, LostConnectionError, NotConnectedError
Expand All @@ -33,6 +34,7 @@ def create_app(test_config=None):
app.register_error_handler(LostConnectionError, handle_lost_connection)
app.register_error_handler(BrokenPipeError, handle_lost_connection)
app.register_error_handler(NotConnectedError, handle_lost_connection)
app.register_error_handler(TimeoutError, handle_timeout)

# load config
app = load_config(app, test_config)
Expand Down
11 changes: 11 additions & 0 deletions src/howitz/error_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,14 @@ def handle_lost_connection(e):
res = make_response()
res.headers['HX-Redirect'] = '/login'
return res


def handle_timeout(e):
current_app.logger.error("Timeout har occurred: %s", e)

response = make_response(render_template('/responses/error-banner.html',
error_message="Timeout has occurred."))

response.headers['HX-Reswap'] = 'beforebegin'

return response, 500
6 changes: 6 additions & 0 deletions src/howitz/templates/responses/error-banner.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<div tabindex="-1"
class="fixed top-0 start-0 z-50 flex justify-center w-full p-4 border-b bg-rose-700 border-rose-600">
<p>
{{ error_message }}
</p>
</div>