improve error handling for elasticsearch