diff --git a/modules/ingest-common/src/test/resources/rest-api-spec/test/ingest/210_pipeline_processor.yml b/modules/ingest-common/src/test/resources/rest-api-spec/test/ingest/210_pipeline_processor.yml index 76dbc180fa0e5..a012536c53bb4 100644 --- a/modules/ingest-common/src/test/resources/rest-api-spec/test/ingest/210_pipeline_processor.yml +++ b/modules/ingest-common/src/test/resources/rest-api-spec/test/ingest/210_pipeline_processor.yml @@ -106,8 +106,8 @@ teardown: id: 1 pipeline: "outer" body: {} -- match: { error.root_cause.0.type: "ingest_processor_exception" } -- match: { error.root_cause.0.reason: "java.lang.IllegalStateException: Cycle detected for pipeline: outer" } +- match: { error.root_cause.0.type: "illegal_state_exception" } +- match: { error.root_cause.0.reason: "Cycle detected for pipeline: outer" } --- "Test Pipeline Processor with templating": @@ -200,5 +200,5 @@ teardown: { "org": "legal" } - - match: { error.root_cause.0.type: "ingest_processor_exception" } - - match: { error.root_cause.0.reason: "java.lang.IllegalStateException: Pipeline processor configured for non-existent pipeline [legal-department]" } + - match: { error.root_cause.0.type: "illegal_state_exception" } + - match: { error.root_cause.0.reason: "Pipeline processor configured for non-existent pipeline [legal-department]" } diff --git a/modules/lang-painless/src/test/resources/rest-api-spec/test/painless/15_update.yml b/modules/lang-painless/src/test/resources/rest-api-spec/test/painless/15_update.yml index 15fcf54ce5a2a..699ce06cb0420 100644 --- a/modules/lang-painless/src/test/resources/rest-api-spec/test/painless/15_update.yml +++ b/modules/lang-painless/src/test/resources/rest-api-spec/test/painless/15_update.yml @@ -124,6 +124,6 @@ source: "ctx._source.ctx = ctx" params: { bar: 'xxx' } - - match: { error.root_cause.0.type: "remote_transport_exception" } + - match: { error.root_cause.0.type: "illegal_argument_exception" } - match: { error.type: "illegal_argument_exception" } - match: { error.reason: "Iterable object is self-referencing itself" } diff --git a/server/src/main/java/org/elasticsearch/ElasticsearchException.java b/server/src/main/java/org/elasticsearch/ElasticsearchException.java index 06c9d69122e9c..190d3ea1364f2 100644 --- a/server/src/main/java/org/elasticsearch/ElasticsearchException.java +++ b/server/src/main/java/org/elasticsearch/ElasticsearchException.java @@ -641,7 +641,7 @@ public static ElasticsearchException[] guessRootCauses(Throwable t) { } } } - return new ElasticsearchException[]{new ElasticsearchException(t.getMessage(), t) { + return new ElasticsearchException[]{new ElasticsearchException(ex.getMessage(), ex) { @Override protected String getExceptionName() { return getExceptionName(getCause()); diff --git a/server/src/test/java/org/elasticsearch/ElasticsearchExceptionTests.java b/server/src/test/java/org/elasticsearch/ElasticsearchExceptionTests.java index 0f9fba891189a..3c8800f383bc5 100644 --- a/server/src/test/java/org/elasticsearch/ElasticsearchExceptionTests.java +++ b/server/src/test/java/org/elasticsearch/ElasticsearchExceptionTests.java @@ -163,6 +163,16 @@ public void testGuessRootCause() { assertEquals("illegal_argument_exception", foobars[0].getExceptionName()); } + { + final ElasticsearchException[] foobars = ElasticsearchException.guessRootCauses( + new RemoteTransportException("abc", new IllegalArgumentException("foobar"))); + assertEquals(foobars.length, 1); + assertThat(foobars[0], instanceOf(ElasticsearchException.class)); + assertEquals("foobar", foobars[0].getMessage()); + assertEquals(IllegalArgumentException.class, foobars[0].getCause().getClass()); + assertEquals("illegal_argument_exception", foobars[0].getExceptionName()); + } + { XContentParseException inner = new XContentParseException(null, "inner"); XContentParseException outer = new XContentParseException(null, "outer", inner); @@ -788,9 +798,7 @@ public void testFailureToAndFromXContentWithDetails() throws IOException { failure = new BroadcastShardOperationFailedException(new ShardId("_index", "_uuid", 5), "F", failureCause); expected = new ElasticsearchException("Elasticsearch exception [type=file_already_exists_exception, reason=File exists]"); - // strangely, the wrapped exception appears as the root cause... - suppressed = new ElasticsearchException("Elasticsearch exception [type=broadcast_shard_operation_failed_exception, " + - "reason=F]"); + suppressed = new ElasticsearchException("Elasticsearch exception [type=file_already_exists_exception, reason=File exists]"); expected.addSuppressed(suppressed); break;