Issue Type:
enhancement
Description:
Very similar to #321. Add a property to Result Components to allow easy display of error messages during error conditions. Error conditions, in my mind, are anything that is preventing search results from showing. This includes any issues with the ElasticSearch server such as 4xx and 5xx errors, or perhaps the service is down, or maybe perhaps ReactiveSearch itself is erroring.
My initial thought is to add a onError property, which is similar to onResultStats and allows the developer to use JSX to either write a simple message or to offer a more advanced component.
+1
+1
This would be very helpful, even just setting some error state in the store would help.
Support for onError on result components has been added.
Instead of rendering a JSX, we have added it as a callback method that gives you the complete error object. You can always handle it and render a JSX element in the container component accordingly.
Should be out in the upcoming release later today! 馃帀
Does the manual need to be updated to include this? Currently onError isn't mentioned as a prop for the result components.
Links: https://opensource.appbase.io/reactive-manual/result-components/resultlist.html#props
https://opensource.appbase.io/reactive-manual/result-components/resultcard.html#props
https://opensource.appbase.io/reactive-manual/result-components/reactivelist.html#props
Thanks for bringing this up @twosdai. We will update the docs to include this.
@jyash97 can you add docs for onError in reactive-manual, please?
@metagrover I've also recently notice that onError doesn't seem to be activating in reactivelist when handed a 400-418 http response code. Is this expected or known behavior?
@lakhansamani you were facing a similar issue, right? Were you able to debug this?
I was able to debug it, basically in your response you need to send an object with status as a property for the onError to fire appropriately. Look at the network response for msearch for the following codesandbox https://codesandbox.io/s/921zy6pl6o All I did was take the example from https://opensource.appbase.io/reactive-manual/result-components/resultlist.html and alter the creds to be bad, and then add the onError property to log the response so that I could verify if it was being called. Which for 401 it was, So I changed my response object to return the object from the example and that solved my problem. @metagrover @lakhansamani
@metagrover Yes I faced the same issue but it was with _msearch query that gets fired,
That needs to be handled in better way, will be creating PR soon for that
Most helpful comment
Support for
onErroron result components has been added.Instead of rendering a JSX, we have added it as a callback method that gives you the complete error object. You can always handle it and render a JSX element in the container component accordingly.
Should be out in the upcoming release later today! 馃帀