fastapi-basic 0.1.9__py3-none-any.whl → 0.1.11__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 fastapi-basic might be problematic. Click here for more details.
- fastapi_basic/base_factory.py +1 -0
- fastapi_basic/exception/base_exception.py +0 -10
- fastapi_basic/ext/line/__init__.py +3 -3
- fastapi_basic/ext/line/exception.py +12 -0
- {fastapi_basic-0.1.9.dist-info → fastapi_basic-0.1.11.dist-info}/METADATA +2 -2
- {fastapi_basic-0.1.9.dist-info → fastapi_basic-0.1.11.dist-info}/RECORD +8 -7
- {fastapi_basic-0.1.9.dist-info → fastapi_basic-0.1.11.dist-info}/WHEEL +0 -0
- {fastapi_basic-0.1.9.dist-info → fastapi_basic-0.1.11.dist-info}/top_level.txt +0 -0
fastapi_basic/base_factory.py
CHANGED
|
@@ -84,6 +84,7 @@ class BaseFactory(metaclass=ABCMeta):
|
|
|
84
84
|
|
|
85
85
|
@app.exception_handler(InternalBaseException)
|
|
86
86
|
async def http_exception_handler(request: Request, exc: InternalBaseException):
|
|
87
|
+
app.logger.warning(f'message: {exc.detail["message"]}')
|
|
87
88
|
return JSONResponse(
|
|
88
89
|
status_code=exc.status_code,
|
|
89
90
|
content={
|
|
@@ -11,13 +11,3 @@ class InternalBaseException(HTTPException):
|
|
|
11
11
|
"data": kwargs,
|
|
12
12
|
}
|
|
13
13
|
super().__init__(status_code=status_code, detail=detail)
|
|
14
|
-
|
|
15
|
-
class LineBotException(HTTPException):
|
|
16
|
-
def __init__(self, status_code: int = status.HTTP_502_BAD_GATEWAY, code: str = "line_bot_error",
|
|
17
|
-
message: str = "Line bot error", **kwargs):
|
|
18
|
-
detail = {
|
|
19
|
-
"code": code,
|
|
20
|
-
"message": message,
|
|
21
|
-
"data": kwargs,
|
|
22
|
-
}
|
|
23
|
-
super().__init__(status_code=status_code, detail=detail)
|
|
@@ -5,7 +5,7 @@ from linebot import LineBotApi, WebhookHandler
|
|
|
5
5
|
from linebot.exceptions import LineBotApiError
|
|
6
6
|
from linebot.models import TextMessage, TextSendMessage, MessageEvent
|
|
7
7
|
|
|
8
|
-
from
|
|
8
|
+
from .exception import LineBotException
|
|
9
9
|
|
|
10
10
|
class LineBot(metaclass=ABCMeta):
|
|
11
11
|
def __init__(self, channel_access_token: str, channel_secret: str, logger=None):
|
|
@@ -24,7 +24,7 @@ class LineBot(metaclass=ABCMeta):
|
|
|
24
24
|
self.log_message(message)
|
|
25
25
|
|
|
26
26
|
except LineBotApiError as err:
|
|
27
|
-
exception = LineBotException(str(err))
|
|
27
|
+
exception = LineBotException(message=str(err))
|
|
28
28
|
raise exception
|
|
29
29
|
|
|
30
30
|
async def push_message(self, line_uid: str, text: str):
|
|
@@ -35,7 +35,7 @@ class LineBot(metaclass=ABCMeta):
|
|
|
35
35
|
|
|
36
36
|
except LineBotApiError as err:
|
|
37
37
|
message = f"Send line message fail, line_uid: {line_uid}, text: {text}, err: {str(err)}"
|
|
38
|
-
exception = LineBotException(message)
|
|
38
|
+
exception = LineBotException(message=message)
|
|
39
39
|
raise exception
|
|
40
40
|
|
|
41
41
|
def log_message(self, log_message: str):
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
from fastapi import status
|
|
2
|
+
from ...exception.base_exception import InternalBaseException
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class LineBotException(InternalBaseException):
|
|
6
|
+
def __init__(self, message: str = "", **kwargs):
|
|
7
|
+
status_code: int = status.HTTP_502_BAD_GATEWAY
|
|
8
|
+
code: str = "line_bot_error"
|
|
9
|
+
log_message: str = "Line bot error"
|
|
10
|
+
|
|
11
|
+
message = f"{log_message}, {message}" if message else log_message
|
|
12
|
+
super().__init__(status_code=status_code, code=code, message=message, **kwargs)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fastapi_basic
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.11
|
|
4
4
|
Summary: A short description of your module
|
|
5
5
|
Home-page: https://github.com/szx21023/fastapi-base
|
|
6
6
|
Author: szx21023
|
|
@@ -35,7 +35,7 @@ Requires-Dist: dotenv==0.9.9
|
|
|
35
35
|
Requires-Dist: fastapi==0.115.12
|
|
36
36
|
Requires-Dist: frozenlist==1.6.0
|
|
37
37
|
Requires-Dist: future==1.0.0
|
|
38
|
-
Requires-Dist: h11==0.
|
|
38
|
+
Requires-Dist: h11==0.16.0
|
|
39
39
|
Requires-Dist: idna==3.10
|
|
40
40
|
Requires-Dist: jmespath==1.0.1
|
|
41
41
|
Requires-Dist: kombu==5.5.3
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
fastapi_basic/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
2
|
fastapi_basic/base_config.py,sha256=WtYA7nI7yTw_bmMMIH1JdKiGOl81Vjekf2OpmwtnCww,568
|
|
3
|
-
fastapi_basic/base_factory.py,sha256=
|
|
3
|
+
fastapi_basic/base_factory.py,sha256=a8AtByr7zp0OQhWzaTkh51KQ_Q_b7XZEF2hcl1rRYCk,4387
|
|
4
4
|
fastapi_basic/const.py,sha256=jjNg7nutqtfzrqEKlU-zbzkDo3ndf3aDc603LbGcB_k,174
|
|
5
5
|
fastapi_basic/utils.py,sha256=8ympyQIXsKkxLILTI_7ug85vmKWYKqX0mpADjgHekgU,306
|
|
6
6
|
fastapi_basic/database/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
7
|
fastapi_basic/database/mongodb.py,sha256=XW7ApqYkR1Jf7LM1HaZ6jzYgajzuu1whKw5cpsjSO-M,1017
|
|
8
8
|
fastapi_basic/exception/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
|
-
fastapi_basic/exception/base_exception.py,sha256=
|
|
9
|
+
fastapi_basic/exception/base_exception.py,sha256=xkpvAI8G96sqXqHgQC_rs2ZPL1liwKVXbXBIPF_8HPQ,473
|
|
10
10
|
fastapi_basic/ext/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
11
|
fastapi_basic/ext/aws/__init__.py,sha256=N_cwnbv1N-F1SY6NenBOTZe20zGaKFu3UXAu17hFAXY,816
|
|
12
12
|
fastapi_basic/ext/aws/const.py,sha256=Mmb6lo11aZZDAVy-nK-v_JxtVPPKYUo9GB4ihH7XYuM,68
|
|
13
|
-
fastapi_basic/ext/line/__init__.py,sha256=
|
|
14
|
-
fastapi_basic
|
|
15
|
-
fastapi_basic-0.1.
|
|
16
|
-
fastapi_basic-0.1.
|
|
17
|
-
fastapi_basic-0.1.
|
|
13
|
+
fastapi_basic/ext/line/__init__.py,sha256=XkFYkV3Mx6w4TRim4ziETJrgOy9qJ_4pPrnqonBE_QU,2128
|
|
14
|
+
fastapi_basic/ext/line/exception.py,sha256=AUJdg15yDUxQe7kys_NiOBqfEgmolj8-y5c2wNgfp2U,490
|
|
15
|
+
fastapi_basic-0.1.11.dist-info/METADATA,sha256=DAmDHtBYTmy-rE_3JIisu_kr0CHeAhdDg_eLaGCpiRM,2753
|
|
16
|
+
fastapi_basic-0.1.11.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
17
|
+
fastapi_basic-0.1.11.dist-info/top_level.txt,sha256=Q9PdwWxaB4dy135MQHiroRYOqArdUSaIeEkzYinN6W0,14
|
|
18
|
+
fastapi_basic-0.1.11.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|