mirror of
https://github.com/checktheroads/hyperglass
synced 2024-05-11 05:55:08 +00:00
Implement global state
This commit is contained in:
@@ -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,
|
||||
)
|
||||
|
Reference in New Issue
Block a user