There is a optional callback for errors occurring, but you might want to also consider adding an error state and setting that when error occur.