arpakitlib 1.5.17__py3-none-any.whl → 1.5.19__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.
Potentially problematic release.
This version of arpakitlib might be problematic. Click here for more details.
- arpakitlib/ar_fastapi_util.py +14 -14
- {arpakitlib-1.5.17.dist-info → arpakitlib-1.5.19.dist-info}/METADATA +1 -1
- {arpakitlib-1.5.17.dist-info → arpakitlib-1.5.19.dist-info}/RECORD +6 -6
- {arpakitlib-1.5.17.dist-info → arpakitlib-1.5.19.dist-info}/LICENSE +0 -0
- {arpakitlib-1.5.17.dist-info → arpakitlib-1.5.19.dist-info}/NOTICE +0 -0
- {arpakitlib-1.5.17.dist-info → arpakitlib-1.5.19.dist-info}/WHEEL +0 -0
arpakitlib/ar_fastapi_util.py
CHANGED
|
@@ -24,7 +24,6 @@ _logger = logging.getLogger(__name__)
|
|
|
24
24
|
|
|
25
25
|
class BaseAPISchema(BaseModel):
|
|
26
26
|
model_config = ConfigDict(extra="ignore", arbitrary_types_allowed=True, from_attributes=True)
|
|
27
|
-
_bus_data: dict[str, Any] = {}
|
|
28
27
|
|
|
29
28
|
@classmethod
|
|
30
29
|
def __pydantic_init_subclass__(cls, **kwargs: Any) -> None:
|
|
@@ -54,13 +53,14 @@ class APIJSONResponse(fastapi.responses.JSONResponse):
|
|
|
54
53
|
)
|
|
55
54
|
|
|
56
55
|
|
|
57
|
-
class
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
56
|
+
class APIErrorCodes(EasyEnumeration):
|
|
57
|
+
cannot_authorize = "CANNOT_AUTHORIZE"
|
|
58
|
+
unknown_error = "UNKNOWN_ERROR"
|
|
59
|
+
error_in_request = "ERROR_IN_REQUEST"
|
|
60
|
+
not_found = "NOT_FOUND"
|
|
61
|
+
|
|
63
62
|
|
|
63
|
+
class APIErrorSO(BaseAPISO):
|
|
64
64
|
has_error: bool = True
|
|
65
65
|
error_code: str | None = None
|
|
66
66
|
error_code_specification: str | None = None
|
|
@@ -73,7 +73,7 @@ class APIException(fastapi.exceptions.HTTPException):
|
|
|
73
73
|
self,
|
|
74
74
|
*,
|
|
75
75
|
status_code: int = starlette.status.HTTP_400_BAD_REQUEST,
|
|
76
|
-
error_code: str | None =
|
|
76
|
+
error_code: str | None = APIErrorCodes.unknown_error,
|
|
77
77
|
error_code_specification: str | None = None,
|
|
78
78
|
error_description: str | None = None,
|
|
79
79
|
error_data: dict[str, Any] | None = None
|
|
@@ -109,7 +109,7 @@ def from_exception_to_api_json_response(
|
|
|
109
109
|
) -> APIJSONResponse:
|
|
110
110
|
easy_api_error_so = APIErrorSO(
|
|
111
111
|
has_error=True,
|
|
112
|
-
error_code=
|
|
112
|
+
error_code=APIErrorCodes.unknown_error
|
|
113
113
|
)
|
|
114
114
|
|
|
115
115
|
status_code = starlette.status.HTTP_500_INTERNAL_SERVER_ERROR
|
|
@@ -120,11 +120,11 @@ def from_exception_to_api_json_response(
|
|
|
120
120
|
elif isinstance(exception, starlette.exceptions.HTTPException):
|
|
121
121
|
status_code = exception.status_code
|
|
122
122
|
if status_code in (starlette.status.HTTP_403_FORBIDDEN, starlette.status.HTTP_401_UNAUTHORIZED):
|
|
123
|
-
easy_api_error_so.error_code =
|
|
123
|
+
easy_api_error_so.error_code = APIErrorCodes.cannot_authorize
|
|
124
124
|
elif status_code == starlette.status.HTTP_404_NOT_FOUND:
|
|
125
|
-
easy_api_error_so.error_code =
|
|
125
|
+
easy_api_error_so.error_code = APIErrorCodes.not_found
|
|
126
126
|
else:
|
|
127
|
-
easy_api_error_so.error_code =
|
|
127
|
+
easy_api_error_so.error_code = APIErrorCodes.unknown_error
|
|
128
128
|
if (
|
|
129
129
|
isinstance(exception.detail, dict)
|
|
130
130
|
or isinstance(exception.detail, list)
|
|
@@ -137,12 +137,12 @@ def from_exception_to_api_json_response(
|
|
|
137
137
|
|
|
138
138
|
elif isinstance(exception, fastapi.exceptions.RequestValidationError):
|
|
139
139
|
status_code = starlette.status.HTTP_422_UNPROCESSABLE_ENTITY
|
|
140
|
-
easy_api_error_so.error_code =
|
|
140
|
+
easy_api_error_so.error_code = APIErrorCodes.error_in_request
|
|
141
141
|
easy_api_error_so.error_data["raw"] = str(exception.errors()) if exception.errors() else {}
|
|
142
142
|
|
|
143
143
|
else:
|
|
144
144
|
status_code = starlette.status.HTTP_500_INTERNAL_SERVER_ERROR
|
|
145
|
-
easy_api_error_so.error_code =
|
|
145
|
+
easy_api_error_so.error_code = APIErrorCodes.unknown_error
|
|
146
146
|
easy_api_error_so.error_data["raw"] = str(exception)
|
|
147
147
|
_logger.exception(exception)
|
|
148
148
|
|
|
@@ -35,7 +35,7 @@ arpakitlib/ar_fastapi_static/swagger-ui/swagger-ui.css,sha256=jzPZlgJTFwSdSphk9C
|
|
|
35
35
|
arpakitlib/ar_fastapi_static/swagger-ui/swagger-ui.css.map,sha256=5wq8eXMLU6Zxb45orZPL1zAsBFJReFw6GjYqGpUX3hg,262650
|
|
36
36
|
arpakitlib/ar_fastapi_static/swagger-ui/swagger-ui.js,sha256=ffrLZHHEQ_g84A-ul3yWa10Kk09waOAxHcQXPuZuavg,339292
|
|
37
37
|
arpakitlib/ar_fastapi_static/swagger-ui/swagger-ui.js.map,sha256=9UhIW7MqCOZPAz1Sl1IKfZUuhWU0p-LJqrnjjJD9Xhc,1159454
|
|
38
|
-
arpakitlib/ar_fastapi_util.py,sha256=
|
|
38
|
+
arpakitlib/ar_fastapi_util.py,sha256=SVKZgq4Oxl5_aJDj-ARyK4ps3_IOU2LAtR54QExg9PU,9607
|
|
39
39
|
arpakitlib/ar_file_storage_in_dir.py,sha256=caS2hRpjKYvK7UNp7qrbSoxT1PfQjJGLOrWEbx-dk-o,3663
|
|
40
40
|
arpakitlib/ar_generate_env_example.py,sha256=aFuHK38bZfGwr57D7AFMCCOOda824o9k95ney_CUbfE,314
|
|
41
41
|
arpakitlib/ar_hash_util.py,sha256=rWKjUaJyzzLNyrMVXe90bcJt0KMkPBPlJGa42qc8zOE,329
|
|
@@ -61,8 +61,8 @@ arpakitlib/ar_str_util.py,sha256=y1KQ5q9WPMhQdmLqqL1R1GrPEEEj_Jo4dxbAPCgW780,187
|
|
|
61
61
|
arpakitlib/ar_type_util.py,sha256=9fSSJKWsHtXOjGcFHgfEI_1ezrHfjF_o3y1RAJvMX9c,1750
|
|
62
62
|
arpakitlib/ar_yookassa_api_client.py,sha256=jCoeK9WfwGK4IUPYYsRgxWEqkNfUV5-ZJQg0b2evtTc,6438
|
|
63
63
|
arpakitlib/ar_zabbix_util.py,sha256=BvtqIT4PnUw4OzzRKPpdu-nLyYZ5cMatYUDeSdXPgGw,6302
|
|
64
|
-
arpakitlib-1.5.
|
|
65
|
-
arpakitlib-1.5.
|
|
66
|
-
arpakitlib-1.5.
|
|
67
|
-
arpakitlib-1.5.
|
|
68
|
-
arpakitlib-1.5.
|
|
64
|
+
arpakitlib-1.5.19.dist-info/LICENSE,sha256=1jqWIkbnMxDfs_i0SXP5qbV6PHjBr1g8506oW7uPjfg,11347
|
|
65
|
+
arpakitlib-1.5.19.dist-info/METADATA,sha256=964TrmWKeKjdqnOumZ4PJDebb1CH861qUnDgGTLIeTc,9326
|
|
66
|
+
arpakitlib-1.5.19.dist-info/NOTICE,sha256=wHwmiq3wExfFfgMsE5U5TOBP9_l72ocIG82KurEels0,43
|
|
67
|
+
arpakitlib-1.5.19.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
|
68
|
+
arpakitlib-1.5.19.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|