diff options
author | Evgeny Zinoviev <me@ch1p.io> | 2024-02-19 04:45:08 +0300 |
---|---|---|
committer | Evgeny Zinoviev <me@ch1p.io> | 2024-02-19 04:45:08 +0300 |
commit | 952e41d59412f5aad5898d0bccb3af800d104f24 (patch) | |
tree | 83fd6258ecd07b4883618fe11047f72b87a3c7dc /include/py/homekit/http/http.py | |
parent | 847ee95d12d65472bf4e9d4c7f50d4b8fc1ea92e (diff) |
web_kbn improvements
Diffstat (limited to 'include/py/homekit/http/http.py')
-rw-r--r-- | include/py/homekit/http/http.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/include/py/homekit/http/http.py b/include/py/homekit/http/http.py index b1d33d3..867fca7 100644 --- a/include/py/homekit/http/http.py +++ b/include/py/homekit/http/http.py @@ -4,7 +4,7 @@ import html from enum import Enum from aiohttp import web -from aiohttp.web import HTTPFound +from aiohttp.web import HTTPFound, HTTPMovedPermanently, HTTPException from aiohttp.web_exceptions import HTTPNotFound from ..util import stringify, format_tb, Addr from ..config import is_development_mode @@ -55,9 +55,17 @@ async def errors_handler_middleware(request, handler): code=404 ) - except HTTPFound as exc: + except (HTTPFound, HTTPMovedPermanently) as exc: raise exc + except HTTPException as exc: + _logger.exception(exc) + return _render_error( + error_type=exc.reason, + error_message=exc.text, + traceback=format_tb(exc) + ) + except Exception as exc: _logger.exception(exc) return _render_error( |