ElasticsearchException esEx = (ElasticsearchException) e.getCause();
Throwable root = esEx.unwrapCause();
if (root instanceof ElasticsearchException) {
return (ElasticsearchException) root;
}
return new UncategorizedExecutionException("Failed execution", root);
} else {
return new UncategorizedExecutionException("Failed execution", e);
}
}