add error handler to xhr calls