nicer error handling on ajax