1
0
Fork 1
mirror of https://github.com/thatmattlove/hyperglass.git synced 2026-01-17 08:48:05 +00:00
thatmattlove-hyperglass/hyperglass/api/error_handlers.py
2020-01-21 17:27:57 -07:00

19 lines
530 B
Python

"""API Error Handlers."""
# Third Party Imports
from starlette.responses import UJSONResponse
async def http_handler(request, exc):
"""Handle web server errors."""
return UJSONResponse(
{"output": exc.detail, "level": "danger", "keywords": []},
status_code=exc.status_code,
)
async def app_handler(request, exc):
"""Handle application errors."""
return UJSONResponse(
{"output": exc.message, "level": exc.level, "keywords": exc.keywords},
status_code=exc.status_code,
)