Better error handling in doXHR