Open samouss opened 5 years ago
probably should be after here, where we this.instantSearchInstance.on('error', error => throw error)
Maybe you can just implement it like this:
import { ErrorHandler } from '@angular/core';
constructor(private error: ErrorHandler) {}
this.instantSearchParent.instantSearchInstance.on('error', error => {
this.error.handleError(error);
});
}
And probably it is best to use the @Output() change
with a sort of Error State. With this people can listen to this error event and do something with it.
This makes lots of sense, and indeed seems to be "the angular" way of rethrowing errors. Would you be interested in doing a PR for that?
Sure, would you like me to implement the ErrorHandler
and the Output eventemitter
? Btw is this the only place where this is happening or are there more places where the Errorhandler
should be implemented?
I think any solution where a user will be able to catch the errors in a ErrorHandler
around InstantSearch is good :)
Right now there is no built-in way to catch error that occurs at the InstantSearch level. Users have to create an custom component scoped under the Provider to get access to the instance and then bind an listener on the error event. Here is an example.
A possible solution is to attach a listener on the
error
event by default, then re-throw the error inside Angular to be able to catch it with a customErrorHandler
.