algo-backend-framework 0.0.3__py3-none-any.whl → 0.0.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- algo_backend/exception/__init__.py +7 -1
- algo_backend/exception/exception.py +31 -3
- algo_backend/handler/__init__.py +1 -1
- algo_backend/handler/exception_to_vo.py +5 -17
- {algo_backend_framework-0.0.3.dist-info → algo_backend_framework-0.0.4.dist-info}/METADATA +1 -1
- {algo_backend_framework-0.0.3.dist-info → algo_backend_framework-0.0.4.dist-info}/RECORD +9 -9
- /algo_backend/handler/{operation_handler.py → simple_handler.py} +0 -0
- {algo_backend_framework-0.0.3.dist-info → algo_backend_framework-0.0.4.dist-info}/WHEEL +0 -0
- {algo_backend_framework-0.0.3.dist-info → algo_backend_framework-0.0.4.dist-info}/top_level.txt +0 -0
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
from .error_code_manage import ApiErrorCodeManage, BasicCodeManage
|
|
2
|
-
from .exception import
|
|
2
|
+
from .exception import (
|
|
3
|
+
BasicApiInnerException,
|
|
4
|
+
BasicCommonException,
|
|
5
|
+
BasicException,
|
|
6
|
+
transfer_exception,
|
|
7
|
+
)
|
|
3
8
|
from .status_code import (
|
|
4
9
|
BasicApiId,
|
|
5
10
|
BasicApiInnerErrorCode,
|
|
@@ -19,4 +24,5 @@ __all__ = [
|
|
|
19
24
|
"BasicCommonException",
|
|
20
25
|
"DefaultApiErrorCode",
|
|
21
26
|
"BasicException",
|
|
27
|
+
"transfer_exception",
|
|
22
28
|
]
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
from typing import TypeVar
|
|
1
|
+
from typing import Optional, TypeVar
|
|
2
2
|
|
|
3
|
-
from .status_code import
|
|
3
|
+
from .status_code import (
|
|
4
|
+
BasicApiId,
|
|
5
|
+
BasicApiInnerErrorCode,
|
|
6
|
+
BasicStatusCode,
|
|
7
|
+
CommonStatusCode,
|
|
8
|
+
add_service_prefix,
|
|
9
|
+
)
|
|
4
10
|
|
|
5
11
|
|
|
6
12
|
class BasicException(Exception):
|
|
@@ -35,8 +41,30 @@ class BasicApiInnerException(BasicException):
|
|
|
35
41
|
def __init__(self, status_code: ET, **kwargs):
|
|
36
42
|
super().__init__(code=status_code.code, msg=status_code.msg.format(**kwargs))
|
|
37
43
|
|
|
38
|
-
def
|
|
44
|
+
def standardize(self, api_id: BasicApiId) -> "BasicApiInnerException":
|
|
45
|
+
"""
|
|
46
|
+
生8位错误码
|
|
47
|
+
:param api_id:
|
|
48
|
+
:return:
|
|
49
|
+
"""
|
|
39
50
|
self.code = BasicApiInnerErrorCode.gen_standard_code(
|
|
40
51
|
api_id=api_id, inner_error_code=self.code
|
|
41
52
|
)
|
|
53
|
+
# 增加两位应用码
|
|
54
|
+
self.code = add_service_prefix(self.code)
|
|
42
55
|
return self
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def transfer_exception(
|
|
59
|
+
e: Exception,
|
|
60
|
+
api_name: Optional[str] = None,
|
|
61
|
+
request_id: Optional[str] = None,
|
|
62
|
+
api_id: Optional[BasicApiId] = None,
|
|
63
|
+
) -> BasicException:
|
|
64
|
+
_params = dict(api_name=api_name, request_id=request_id)
|
|
65
|
+
if isinstance(e, BasicCommonException):
|
|
66
|
+
return e
|
|
67
|
+
elif isinstance(e, BasicApiInnerException):
|
|
68
|
+
return e.standardize(api_id=api_id)
|
|
69
|
+
else:
|
|
70
|
+
return BasicCommonException(CommonStatusCode.UNKNOWN_ERROR, msg=str(e))
|
algo_backend/handler/__init__.py
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
from typing import Optional
|
|
3
3
|
|
|
4
|
-
from algo_backend.exception import
|
|
5
|
-
BasicApiId,
|
|
6
|
-
BasicApiInnerException,
|
|
7
|
-
BasicCommonException,
|
|
8
|
-
CommonStatusCode,
|
|
9
|
-
)
|
|
4
|
+
from algo_backend.exception import BasicApiId, transfer_exception
|
|
10
5
|
from algo_backend.schema import AbstractRespVo
|
|
11
6
|
|
|
12
7
|
logger = logging.getLogger(__name__)
|
|
@@ -24,14 +19,7 @@ def gen_vo_from_exception(
|
|
|
24
19
|
"""
|
|
25
20
|
|
|
26
21
|
_params = dict(api_name=api_name, request_id=request_id)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
else:
|
|
32
|
-
vo = vo_cls.from_exception(
|
|
33
|
-
BasicCommonException(CommonStatusCode.UNKNOWN_ERROR, msg=str(e)),
|
|
34
|
-
**_params,
|
|
35
|
-
)
|
|
36
|
-
|
|
37
|
-
return vo
|
|
22
|
+
return vo_cls.from_exception(
|
|
23
|
+
transfer_exception(e, api_name=api_name, request_id=request_id, api_id=api_id),
|
|
24
|
+
**_params,
|
|
25
|
+
)
|
|
@@ -2,13 +2,13 @@ algo_backend/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
2
2
|
algo_backend/config/__init__.py,sha256=MLAvcvodxXiaVsSJaVvQcNjFWIFusBQ0i9OrWJv3zv0,222
|
|
3
3
|
algo_backend/config/basic_config.py,sha256=RSRf8lgc8KfA_FHNjchaghSLNnJy7ejn2ux57SBSakg,292
|
|
4
4
|
algo_backend/config/loguru_config.py,sha256=WovghKcMqeysPuf8vlKFhbNug8Z7zPqxkjlwVYKjZWw,513
|
|
5
|
-
algo_backend/exception/__init__.py,sha256=
|
|
5
|
+
algo_backend/exception/__init__.py,sha256=tHC3p8DyCrFHW4WvLEOuPKP5t4yVqhc1flcWQRtz5AY,653
|
|
6
6
|
algo_backend/exception/error_code_manage.py,sha256=d29aMgelf93RUqlvLTjQDxBiSH9ZVFYbW66rzTWDKM4,4391
|
|
7
|
-
algo_backend/exception/exception.py,sha256=
|
|
7
|
+
algo_backend/exception/exception.py,sha256=Gz5LDsqRct8LON1Aq43TdqQQjyC4_Uy9yeUlO7XtPnM,1962
|
|
8
8
|
algo_backend/exception/status_code.py,sha256=s5lXXR-oSALk3gtI4KcPKHstvnRFArQL1SEgQFIeSxU,2707
|
|
9
|
-
algo_backend/handler/__init__.py,sha256=
|
|
10
|
-
algo_backend/handler/exception_to_vo.py,sha256=
|
|
11
|
-
algo_backend/handler/
|
|
9
|
+
algo_backend/handler/__init__.py,sha256=QUWn5MmDUzqbq_gcoSpMZtPMgfzrkLnlwDbLksXwQVE,104
|
|
10
|
+
algo_backend/handler/exception_to_vo.py,sha256=uX3JZaPP5Zt1RgJunFfumxpSfWHwcWtKLZ21dIXDraQ,687
|
|
11
|
+
algo_backend/handler/simple_handler.py,sha256=7ffsgjj1EZ_d3x_jx9krju_uwCmwfjXHJ_9KZ8SrpOw,2654
|
|
12
12
|
algo_backend/intercept/__init__.py,sha256=FoNHCzUc3ceLo85ECN3L7HzW6KmLqcG5sgMh_qULLdw,265
|
|
13
13
|
algo_backend/intercept/common.py,sha256=T50_IAeY0HQ8TbupjYvMHMObg3j9I4lQnqZMiWNzuQw,1445
|
|
14
14
|
algo_backend/intercept/http.py,sha256=C_N2nyErFhdOZ1LPQ6iU_JCy4fFYEucDwhWJb-qBnbc,1381
|
|
@@ -42,7 +42,7 @@ algo_backend/starter/event_list.py,sha256=vQHzQIpW8LZmQ93YyET-1gX6pQGVE5A6I_pLoY
|
|
|
42
42
|
algo_backend/utils/__init__.py,sha256=oX6OyL-28jzc94u4fyH1TtntCzQySkfZ8jibMk1KPU8,168
|
|
43
43
|
algo_backend/utils/meta_class.py,sha256=hcZPGF7EIHvJOXXR82_7Gah_AWbqkcSxUc473I_6maY,1850
|
|
44
44
|
algo_backend/utils/utils.py,sha256=q3bxBrivndLRggWsLryloSpu-_Ecbj4mhZL8oYdiDTo,481
|
|
45
|
-
algo_backend_framework-0.0.
|
|
46
|
-
algo_backend_framework-0.0.
|
|
47
|
-
algo_backend_framework-0.0.
|
|
48
|
-
algo_backend_framework-0.0.
|
|
45
|
+
algo_backend_framework-0.0.4.dist-info/METADATA,sha256=dX_eOI1tqlVzXmJjDu9S6J7h8EtEtWyOeFAysoSp5CI,2196
|
|
46
|
+
algo_backend_framework-0.0.4.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
47
|
+
algo_backend_framework-0.0.4.dist-info/top_level.txt,sha256=zLsbLTRV1tO2hQfazqiBLO73VnjSAhJSUpMMBmQaLfw,13
|
|
48
|
+
algo_backend_framework-0.0.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
{algo_backend_framework-0.0.3.dist-info → algo_backend_framework-0.0.4.dist-info}/top_level.txt
RENAMED
|
File without changes
|