MCPcopy Create free account
hub / github.com/Tencent/CodeAnalysis / __deco

Function __deco

server/projects/main/util/webclients.py:29–47  ·  view source on GitHub ↗
(*args, **kwargs)

Source from the content-addressed store, hash-verified

27 """装饰器
28 """
29 def __deco(*args, **kwargs):
30 rsp = func(*args, **kwargs)
31 result = rsp.data.decode("utf-8")
32 # 正常返回
33 if 200 <= rsp.status < 300:
34 if result:
35 return json.loads(result)
36 else:
37 return result
38 else:
39 # 其他错误,如请求参数错误
40 logger.error(result)
41 # 系统错误
42 if rsp.status >= 500:
43 raise CDErrorBase(errcode.E_SERVER, "server return code[%d] %s with params %s" % (
44 rsp.status, result, str(args)))
45 else:
46 raise CDErrorBase(errcode.E_CLIENT, "server return code[%d] %s with params %s" % (
47 rsp.status, result, str(args)), data=result)
48
49 return __deco
50

Callers

nothing calls this directly

Calls 2

CDErrorBaseClass · 0.90
errorMethod · 0.80

Tested by

no test coverage detected