Files
aicheckv2/app/application/exception_handler.py
2025-03-11 11:42:09 +08:00

16 lines
491 B
Python

from fastapi import HTTPException, Request
from app.common.reponse_code import response_error
from app import my_app
"""全局异常处理"""
@my_app.exception_handlers(HTTPException)
async def http_exception(request: Request, he: HTTPException):
return response_error(request.url + "出现异常:" + he.detail)
@my_app.exception_handlers(Exception)
async def http_exception(request: Request, he: Exception):
return response_error(request.url + "出现异常:" + he.detail)