Improved error handling in Invoke-ElasticSearch