mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-17 10:25:15 +00:00
[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
|
||||
if (tasks.isEmpty()) {
|
||||
if (taskOperationFailures.isEmpty() == false) {
|
||||
throw new ElasticsearchException(taskOperationFailures.get(0).getCause());
|
||||
throw wrapThrowable(taskOperationFailures.get(0).getCause());
|
||||
} else if (failedNodeExceptions.isEmpty() == false) {
|
||||
throw new ElasticsearchException(failedNodeExceptions.get(0).getCause());
|
||||
throw wrapThrowable(failedNodeExceptions.get(0).getCause());
|
||||
} else {
|
||||
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
|
||||
protected boolean accumulateExceptions() {
|
||||
return false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user