Skip to content

Commit 99e702c

Browse files
committed
fix: improve get_objs exception handling
1 parent 93305aa commit 99e702c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

easy/controller/meta.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,18 @@ async def del_obj(self, request: HttpRequest, id: int) -> Any: # type: ignore
8282
return BaseApiResponse("Not Found.", code=404)
8383

8484
@paginate
85-
async def get_objs(self, request: HttpRequest, filters: str = None) -> Any: # type: ignore
85+
async def get_objs(self, request: HttpRequest, filters: Optional[str] = None) -> Any: # type: ignore
8686
"""
8787
GET /?filters={filters_dict}
8888
Retrieve multiple Object (optional: django filters)
8989
"""
9090
if filters:
91-
return await self.service.get_objs(**json.loads(filters))
91+
try:
92+
_filters = json.loads(filters)
93+
except Exception as exc: # pragma: no cover
94+
logger.warning(str(exc), exc_info=True)
95+
return []
96+
return await self.service.get_objs(**_filters)
9297
return await self.service.get_objs()
9398

9499
if model_opts.generate_crud and model_opts.model:

0 commit comments

Comments
 (0)