mirror of
https://github.com/checktheroads/hyperglass
synced 2024-05-11 05:55:08 +00:00
migrate api to module
This commit is contained in:
19
hyperglass/api/error_handlers.py
Normal file
19
hyperglass/api/error_handlers.py
Normal file
@@ -0,0 +1,19 @@
|
||||
"""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,
|
||||
)
|
Reference in New Issue
Block a user