searchkit / searchkit

React + Vue Search UI for Elasticsearch & Opensearch. Compatible with Algolia's Instantsearch and Autocomplete components.
http://www.searchkit.co/docs
Apache License 2.0
4.78k stars 442 forks source link

Exposing ElasticSearch errors to InstantSearch #1257

Open McManning opened 1 year ago

McManning commented 1 year ago

The problem

It'd be nice if errors raised from ElasticSearch would bubble up in some way to the InstantSearch state so that we can provide better feedback to the user as to why something failed. Otherwise, one of the InstantSearch filter/facet components ends up throwing a generic "Cannot convert undefined or null to object" when dealing with bad results.

Environment

Details

One good place to add support would be in performSearch where backend errors are just logged to the console.

It looks like InstantSearch does support catching errors from downstream components via middleware (see: https://www.algolia.com/doc/guides/building-search-ui/going-further/conditional-display/react-hooks/#handling-errors) so it might be possible that simply throwing an error could be caught and handled.

joemcelroy commented 1 year ago

Could you find out the error structure? Happy for you to do a PR fix for this!!