Skip to content
This repository was archived by the owner on May 28, 2023. It is now read-only.

Commit 5df0413

Browse files
author
Fifciuu
committed
fix: build query in try catch block
1 parent 84c1ace commit 5df0413

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/api/catalog.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,14 @@ export default ({config, db}) => async function (req, res, body) {
6565
}
6666

6767
if (req.query.request_format === 'search-query') { // search query and not Elastic DSL - we need to translate it
68-
const customFilters = await loadCustomFilters(config)
69-
requestBody = await elasticsearch.buildQueryBodyFromSearchQuery({ config, queryChain: bodybuilder(), searchQuery: new SearchQuery(requestBody), customFilters })
68+
try {
69+
const customFilters = await loadCustomFilters(config)
70+
requestBody = await elasticsearch.buildQueryBodyFromSearchQuery({ config, queryChain: bodybuilder(), searchQuery: new SearchQuery(requestBody), customFilters })
71+
} catch (err) {
72+
console.error(err);
73+
apiError(res, err);
74+
return;
75+
}
7076
}
7177
if (req.query.response_format) responseFormat = req.query.response_format
7278

0 commit comments

Comments
 (0)