Improve error handling when connecting to elasticsearch

Raise critical errors if we have problems connecting to elasticsearch