1
0
mirror of https://github.com/checktheroads/hyperglass synced 2024-05-11 05:55:08 +00:00

Implement global state

This commit is contained in:
thatmattlove
2021-09-15 00:57:45 -07:00
parent b002c9d520
commit a2ee4b50fa
29 changed files with 702 additions and 345 deletions

View File

@@ -4,18 +4,21 @@
from starlette.responses import JSONResponse
# Project
from hyperglass.configuration import params
from hyperglass.state import use_state
async def default_handler(request, exc):
"""Handle uncaught errors."""
state = use_state()
return JSONResponse(
{"output": params.messages.general, "level": "danger", "keywords": []}, status_code=500,
{"output": state.params.messages.general, "level": "danger", "keywords": []},
status_code=500,
)
async def http_handler(request, exc):
"""Handle web server errors."""
return JSONResponse(
{"output": exc.detail, "level": "danger", "keywords": []}, status_code=exc.status_code,
)