How should I gracefully handle exceptions like thi...
# community-help
c
How should I gracefully handle exceptions like this from typesense.js? Error boundaries in React don't seem to work, and I can't find any kind of
onError
type of callbacks. Edit: I'm using the typesense instantsearch adapter, so not just typesense.js directly
j
This needs to be handled via InstantSearch. Do the solutions in this thread work: https://github.com/algolia/react-instantsearch/issues/1144
c
Nope, I found that earlier and tried multiple ways to create a react error boundary, but I think something may be catching it, or it's event driven in which case the boundary won't catch it. There is the chance I did it completely wrong of course, and if you think it should have worked, I can try again.
j
I haven’t tried this out myself, so I’m not sure if this works… But did you specifically try the 2nd code snippet here: https://github.com/algolia/react-instantsearch/issues/1144#issuecomment-378939730 with
connectStateResults
?
c
We've moved to the hooks version, which doesn't seem to have an option for that connector. As in, I couldn't find a hook for it, and I can't seem to see a connector in https://github.com/algolia/instantsearch.js/tree/master/src/connectors to make our own hook 😐 Though this isn't a typesense problem, so I don't expect you to answer that. Just thought maybe the typesense adapter is somehow not re-throwing the error properly. Especially since in the first issue you link to, the more recent comment he is making use of
typesense-instantsearch-adapter
too
j
Just thought maybe the typesense adapter is somehow not re-throwing the error properly.
I suspected this too… But I do re-throw any errors here: https://github.com/typesense/typesense-instantsearch-adapter/blob/3ac546dbe91d3f3ff5f392d39e7f2e3fcf5bdec0/src/TypesenseInstantsearchAdapter.js#L40
We’ve moved to the hooks version, which doesn’t seem to have an option for that connector. As in, I couldn’t find a hook for it,
May be this could be a feature request for the hooks lib to expose
👍 1
c
Yeh I saw that too earlier when I was checking the typesense source 😅 Don't worry about it though, I think the hooks should really expose an "error" state as it did before with
react-instantsearch
. I was basically trying to work around it using error boundaries.
Yeh for sure, though I think one was already there. I'll have a check again. Cheers for the investigation though man
👍 1