crypticorn 2.7.4__py3-none-any.whl → 2.7.5__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.
- crypticorn/common/exceptions.py +13 -7
- {crypticorn-2.7.4.dist-info → crypticorn-2.7.5.dist-info}/METADATA +1 -1
- {crypticorn-2.7.4.dist-info → crypticorn-2.7.5.dist-info}/RECORD +6 -6
- {crypticorn-2.7.4.dist-info → crypticorn-2.7.5.dist-info}/WHEEL +1 -1
- {crypticorn-2.7.4.dist-info → crypticorn-2.7.5.dist-info}/entry_points.txt +0 -0
- {crypticorn-2.7.4.dist-info → crypticorn-2.7.5.dist-info}/top_level.txt +0 -0
crypticorn/common/exceptions.py
CHANGED
@@ -5,7 +5,9 @@ from fastapi import HTTPException as FastAPIHTTPException, Request, FastAPI
|
|
5
5
|
from fastapi.exceptions import RequestValidationError, ResponseValidationError
|
6
6
|
from fastapi.responses import JSONResponse
|
7
7
|
from crypticorn.common import ApiError, ApiErrorIdentifier, ApiErrorType, ApiErrorLevel
|
8
|
+
import logging
|
8
9
|
|
10
|
+
logger = logging.getLogger(__name__)
|
9
11
|
|
10
12
|
class ExceptionType(StrEnum):
|
11
13
|
HTTP = "http"
|
@@ -91,35 +93,39 @@ class WebSocketException(HTTPException):
|
|
91
93
|
|
92
94
|
async def general_handler(request: Request, exc: Exception):
|
93
95
|
"""This is the default exception handler for all exceptions."""
|
94
|
-
body = ExceptionContent(message=str(exc), error=ApiError.UNKNOWN_ERROR)
|
96
|
+
body = ExceptionContent(message=str(exc), error=ApiError.UNKNOWN_ERROR).enrich()
|
97
|
+
logger.error(f"Unknown error: {body.detail}")
|
95
98
|
return JSONResponse(
|
96
|
-
status_code=body.
|
99
|
+
status_code=body.status_code, content=HTTPException(content=body).detail
|
97
100
|
)
|
98
101
|
|
99
102
|
|
100
103
|
async def request_validation_handler(request: Request, exc: RequestValidationError):
|
101
104
|
"""This is the exception handler for all request validation errors."""
|
102
|
-
body = ExceptionContent(message=str(exc), error=ApiError.INVALID_DATA_REQUEST)
|
105
|
+
body = ExceptionContent(message=str(exc), error=ApiError.INVALID_DATA_REQUEST).enrich()
|
106
|
+
logger.error(f"Request validation error: {body.detail}")
|
103
107
|
return JSONResponse(
|
104
|
-
status_code=body.
|
108
|
+
status_code=body.status_code, content=HTTPException(content=body).detail
|
105
109
|
)
|
106
110
|
|
107
111
|
|
108
112
|
async def response_validation_handler(request: Request, exc: ResponseValidationError):
|
109
113
|
"""This is the exception handler for all response validation errors."""
|
110
|
-
body = ExceptionContent(message=str(exc), error=ApiError.INVALID_DATA_RESPONSE)
|
114
|
+
body = ExceptionContent(message=str(exc), error=ApiError.INVALID_DATA_RESPONSE).enrich()
|
115
|
+
logger.error(f"Response validation error: {body.detail}")
|
111
116
|
return JSONResponse(
|
112
|
-
status_code=body.
|
117
|
+
status_code=body.status_code, content=HTTPException(content=body).detail
|
113
118
|
)
|
114
119
|
|
115
120
|
|
116
121
|
async def http_handler(request: Request, exc: HTTPException):
|
117
122
|
"""This is the exception handler for HTTPExceptions. It unwraps the HTTPException and returns the detail in a flat JSON response."""
|
123
|
+
logger.error(f"HTTP error: {exc.detail}")
|
118
124
|
return JSONResponse(status_code=exc.status_code, content=exc.detail)
|
119
125
|
|
120
126
|
|
121
127
|
def register_exception_handlers(app: FastAPI):
|
122
|
-
"""Utility to register serveral exception handlers in one go. Catches Exception, HTTPException and Data Validation errors and responds with a unified json body."""
|
128
|
+
"""Utility to register serveral exception handlers in one go. Catches Exception, HTTPException and Data Validation errors, logs them and responds with a unified json body."""
|
123
129
|
app.add_exception_handler(Exception, general_handler)
|
124
130
|
app.add_exception_handler(FastAPIHTTPException, http_handler)
|
125
131
|
app.add_exception_handler(RequestValidationError, request_validation_handler)
|
@@ -68,7 +68,7 @@ crypticorn/common/auth.py,sha256=60SRXlW72VJO8rGzCiemWmzGu8tXDqWr0wt9EM6p8aI,863
|
|
68
68
|
crypticorn/common/decorators.py,sha256=pmnGYCIrLv59wZkDbvPyK9NJmgPJWW74LXTdIWSjOkY,1063
|
69
69
|
crypticorn/common/enums.py,sha256=RitDVqlG_HTe6tHT6bWusZNFCeYk1eQvJVH-7x3_Zlg,668
|
70
70
|
crypticorn/common/errors.py,sha256=8jxZ2lLn_NoFKKq6n2JwKPsR0dA2vkGnbXDfEK6ndH0,27851
|
71
|
-
crypticorn/common/exceptions.py,sha256=
|
71
|
+
crypticorn/common/exceptions.py,sha256=FOxScGTnAoiBkpC5lccQ6_b1jIPcWxawZvR_H2KBCNY,5953
|
72
72
|
crypticorn/common/mixins.py,sha256=LKPcNTR8uREeDGWTlWozNx7rS1mYdQVx1RllLhxIAsE,1640
|
73
73
|
crypticorn/common/pagination.py,sha256=c07jrMNrBaNTmgx4sppdP7ND4RNT7NBqBXWvofazIlE,2251
|
74
74
|
crypticorn/common/scopes.py,sha256=gbxrzME18ASQS18IHg96TvFZxh5-O8ffD2caGpfs0lc,2333
|
@@ -224,8 +224,8 @@ crypticorn/trade/client/models/strategy_model_input.py,sha256=ala19jARyfA5ysys5D
|
|
224
224
|
crypticorn/trade/client/models/strategy_model_output.py,sha256=2o2lhbgUSTznowpMLEHF1Ex9TG9oRmzlCIb-gXqo7_s,5643
|
225
225
|
crypticorn/trade/client/models/tpsl.py,sha256=C2KgTIZs-a8W4msdaXgBKJcwtA-o5wR4rBauRP-iQxU,4317
|
226
226
|
crypticorn/trade/client/models/trading_action_type.py,sha256=pGq_TFLMPfYFizYP-xKgEC1ZF4U3lGdJYoGa_ZH2x-Q,769
|
227
|
-
crypticorn-2.7.
|
228
|
-
crypticorn-2.7.
|
229
|
-
crypticorn-2.7.
|
230
|
-
crypticorn-2.7.
|
231
|
-
crypticorn-2.7.
|
227
|
+
crypticorn-2.7.5.dist-info/METADATA,sha256=5E_LCIIfd_O0t6Q8HBqaVLQVSvq_xgvVmMiCgPW_AZU,6607
|
228
|
+
crypticorn-2.7.5.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
|
229
|
+
crypticorn-2.7.5.dist-info/entry_points.txt,sha256=d_xHsGvUTebPveVUK0SrpDFQ5ZRSjlI7lNCc11sn2PM,59
|
230
|
+
crypticorn-2.7.5.dist-info/top_level.txt,sha256=EP3NY216qIBYfmvGl0L2Zc9ItP0DjGSkiYqd9xJwGcM,11
|
231
|
+
crypticorn-2.7.5.dist-info/RECORD,,
|
File without changes
|
File without changes
|