Skip to content

Commit a12e5b6

Browse files
bors[bot]bidoubiwa
andauthored
Merge #216
216: Add error information in console r=bidoubiwa a=bidoubiwa Best I could do given that the problem comes from algolia itself: <img width="960" alt="Screenshot 2021-01-16 at 23 28 02" src="https://user-images.githubusercontent.com/33010418/104824592-5403d800-5853-11eb-8e53-dfdd5a384cc1.png"> First error shown is our error, second is the unhandled error of algolia. Maybe a more deep dive search could help us find a solution where algolia's unhandled error would not appear. But meanwhile, the user is aware of its errors. fixes meilisearch/meilisearch-vue#7 fixes #216 Co-authored-by: Charlotte Vermandel <[email protected]>
2 parents c6ce252 + ed0f457 commit a12e5b6

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

src/index.js

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -92,23 +92,28 @@ export default function instantMeiliSearch(hostUrl, apiKey, options = {}) {
9292
},
9393

9494
search: async function (requests) {
95-
// Params got from InstantSearch
96-
const params = requests[0].params
97-
this.pagination = params.page !== undefined // If the pagination widget has been set
98-
this.hitsPerPage = params.hitsPerPage || 20 // 20 is the MeiliSearch's default limit value. `hitsPerPage` can be changed with `InsantSearch.configure`.
99-
// Gets information from IS and transforms it for MeiliSearch
100-
const searchInput = this.transformToMeiliSearchParams(params)
101-
const indexUid = requests[0].indexName
102-
// Executes the search with MeiliSearch
103-
const searchResponse = await this.client
104-
.index(indexUid)
105-
.search(searchInput.q, searchInput)
106-
// Parses the MeiliSearch response and returns it for InstantSearch
107-
return this.parseMeiliSearchResponse(
108-
indexUid,
109-
searchResponse,
110-
requests[0].params
111-
)
95+
try {
96+
// Params got from InstantSearch
97+
const params = requests[0].params
98+
this.pagination = params.page !== undefined // If the pagination widget has been set
99+
this.hitsPerPage = params.hitsPerPage || 20 // 20 is the MeiliSearch's default limit value. `hitsPerPage` can be changed with `InsantSearch.configure`.
100+
// Gets information from IS and transforms it for MeiliSearch
101+
const searchInput = this.transformToMeiliSearchParams(params)
102+
const indexUid = requests[0].indexName
103+
// Executes the search with MeiliSearch
104+
const searchResponse = await this.client
105+
.index(indexUid)
106+
.search(searchInput.q, searchInput)
107+
// Parses the MeiliSearch response and returns it for InstantSearch
108+
return await this.parseMeiliSearchResponse(
109+
indexUid,
110+
searchResponse,
111+
requests[0].params
112+
)
113+
} catch (e) {
114+
console.error(e)
115+
throw new Error(e)
116+
}
112117
},
113118
}
114119
}

0 commit comments

Comments
 (0)