Allow adding onError callback and that should only be called on error, with the details of the error.
The problem with current implementation is if stopOnError is set to false, it keep working, but we don't know if the callback was failed. We can add try/catch in the callback, but that would add lot of boilerplate code.
It will be helpful when we want to do certain task if the callback is failed, for example, I want to log the error to a third party service like datadog or newrelic, or I want to stop the execution of this method if the it failed for the 3 time continuously.
Allow adding
onErrorcallback and that should only be called on error, with the details of the error.The problem with current implementation is if
stopOnErroris set to false, it keep working, but we don't know if the callback was failed. We can add try/catch in the callback, but that would add lot of boilerplate code.It will be helpful when we want to do certain task if the callback is failed, for example, I want to log the error to a third party service like
datadogornewrelic, or I want to stop the execution of this method if the it failed for the 3 time continuously.