[ML] Use ExceptionsHelper.convertToElastic to wrap exceptions in TransportJobTaskAction (elastic/x-pack-elasticsearch#577)
* Wrap exceptions if they are not ElasticsearchExceptions in TransportJobTaskAction * Review comments Original commit: elastic/x-pack-elasticsearch@07e900ffaa
This commit is contained in:
parent
45ecebac20
commit
f82634b6b1
|
@ -96,9 +96,9 @@ public abstract class TransportJobTaskAction<OperationTask extends Task, Request
|
||||||
// the actionlistener's onFailure
|
// the actionlistener's onFailure
|
||||||
if (tasks.isEmpty()) {
|
if (tasks.isEmpty()) {
|
||||||
if (taskOperationFailures.isEmpty() == false) {
|
if (taskOperationFailures.isEmpty() == false) {
|
||||||
throw new ElasticsearchException(taskOperationFailures.get(0).getCause());
|
throw wrapThrowable(taskOperationFailures.get(0).getCause());
|
||||||
} else if (failedNodeExceptions.isEmpty() == false) {
|
} else if (failedNodeExceptions.isEmpty() == false) {
|
||||||
throw new ElasticsearchException(failedNodeExceptions.get(0).getCause());
|
throw wrapThrowable(failedNodeExceptions.get(0).getCause());
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalStateException("No errors or response");
|
throw new IllegalStateException("No errors or response");
|
||||||
}
|
}
|
||||||
|
@ -110,6 +110,14 @@ public abstract class TransportJobTaskAction<OperationTask extends Task, Request
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ElasticsearchException wrapThrowable(Throwable th) {
|
||||||
|
if (th instanceof ElasticsearchException) {
|
||||||
|
return (ElasticsearchException) th;
|
||||||
|
} else {
|
||||||
|
return new ElasticsearchException(th);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean accumulateExceptions() {
|
protected boolean accumulateExceptions() {
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue