| 31 | def decorator(func): |
| 32 | @wraps(func) |
| 33 | async def wrapper(*args, **kwargs): |
| 34 | try: |
| 35 | return await func(*args, **kwargs) |
| 36 | except HTTPException as e: |
| 37 | raise e |
| 38 | except Exception: |
| 39 | support_id = str(uuid4()) |
| 40 | |
| 41 | log.error("--- HANDLING EXCEPTION ---") |
| 42 | log.error(f"support_id={support_id} & operation_id={func.__name__}") |
| 43 | log.error(f"{format_exc()}") |
| 44 | log.error("--------------------------") |
| 45 | |
| 46 | raise HTTPException( |
| 47 | status_code=500, |
| 48 | detail=f"An unexpected error occurred with operation_id={func.__name__}. Please contact support with support_id={support_id}.", |
| 49 | ) |
| 50 | |
| 51 | return wrapper |
| 52 | |