Updated this to the latest version of develop, got rid of most of the duplication, might be missing some packages in toml, needs testing

This commit is contained in:
Carlos Mesquita
2024-08-30 02:35:11 +01:00
parent 3cf9fa5cba
commit f92a803d96
73 changed files with 3642 additions and 2703 deletions

5
app/utils/__init__.py Normal file
View File

@@ -0,0 +1,5 @@
from .handle_exception import handle_exception
__all__ = [
"handle_exception"
]

View File

@@ -0,0 +1,15 @@
import functools
from typing import Callable, Any
from fastapi import Response
def handle_exception(status_code: int = 500):
def decorator(func: Callable) -> Callable:
@functools.wraps(func)
async def wrapper(*args: Any, **kwargs: Any) -> Any:
try:
return await func(*args, **kwargs)
except Exception as e:
return Response(content=str(e), status_code=status_code)
return wrapper
return decorator