Skip to content

Commit a491b14

Browse files
committed
fix: handle 404 response in get_creator_post API
fixes #315
1 parent b0f29ca commit a491b14

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

ktoolbox/api/posts/get_creator_post.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
from typing import List
1+
from typing import List, TypeVar
22

3+
import httpx
34
from pydantic import RootModel
45

56
from ktoolbox.api import BaseAPI, APIRet
67
from ktoolbox.api.model import Post
78

89
__all__ = ["GetCreatorPost", "get_creator_post"]
910

11+
_T = TypeVar('_T')
12+
1013

1114
class GetCreatorPost(BaseAPI):
1215
path = "/{service}/user/{creator_id}/posts"
@@ -33,5 +36,9 @@ async def __call__(cls, service: str, creator_id: str, *, q: str = None, o: int
3336
}
3437
)
3538

39+
@classmethod
40+
def handle_res(cls, res: httpx.Response) -> APIRet[_T]:
41+
return APIRet(data=[]) if res.status_code == 404 else super().handle_res(res)
42+
3643

3744
get_creator_post = GetCreatorPost.__call__

0 commit comments

Comments
 (0)