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 15e93bf621c7e..cb118ed9d562f 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 @@ -120,6 +120,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 abaceff4f4e73..f588823f699b3 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 9ed826de87cdd..570598831f944 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);