Add smarter handling of ES errors