Error handling for sync ajax