Skip to content

Commit

Permalink
Try catch for filters
Browse files Browse the repository at this point in the history
  • Loading branch information
kshitijrajsharma committed Jan 29, 2024
1 parent 3b27844 commit b7854b2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 4 additions & 2 deletions API/hdx.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ async def read_hdx_list(
filters[f"{key} = %s"] = values
continue
filters[f"dataset->>'{key}' = %s"] = values

hdx_list = hdx_instance.get_hdx_list_with_filters(skip, limit, filters)
try:
hdx_list = hdx_instance.get_hdx_list_with_filters(skip, limit, filters)
except Exception as ex:
raise HTTPException(status_code=422, detail="Couldn't process query")
return hdx_list


Expand Down
2 changes: 2 additions & 0 deletions src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1970,7 +1970,9 @@ def get_hdx_list_with_filters(
OFFSET %s LIMIT %s
"""
)

self.cur.execute(select_query, tuple(filter_values) + (skip, limit))

result = self.cur.fetchall()
self.d_b.close_conn()
return [orjson.loads(item[0]) for item in result]
Expand Down

0 comments on commit b7854b2

Please sign in to comment.