解锁并提取Linux客户端微信数据库 (vibe coded)
at 37 lines 1.1 kB view raw
1# -*- coding: utf-8 -*-# 2# ------------------------------------------------------------------------------- 3# Name: decorators.py 4# Description: Error handling decorators for API endpoints 5# Author: xaoyaoo 6# Date: 2024/01/16 7# ------------------------------------------------------------------------------- 8import traceback 9from functools import wraps 10 11from .response import ReJson 12 13 14def error9999(func): 15 @wraps(func) 16 def wrapper(*args, **kwargs): 17 try: 18 return func(*args, **kwargs) 19 except Exception as e: 20 traceback_data = traceback.format_exc() 21 rdata = f"{traceback_data}" 22 return ReJson(9999, body=f"{str(e)}\n{rdata}", error=str(e)) 23 24 return wrapper 25 26 27def asyncError9999(func): 28 @wraps(func) 29 async def wrapper(*args, **kwargs): 30 try: 31 return await func(*args, **kwargs) 32 except Exception as e: 33 traceback_data = traceback.format_exc() 34 rdata = f"{traceback_data}" 35 return ReJson(9999, body=f"{str(e)}\n{rdata}", error=str(e)) 36 37 return wrapper