Skip to content

Commit 8485bc7

Browse files
committed
Add a test showing stack-trace preservation
Related to #1399
1 parent 350e11c commit 8485bc7

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/Tests/Nest.Tests.Integration/Exceptions/ElasticsearchExceptionTests.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,19 @@ public void ConnectionException_WithThrowingClient_Async()
4747
.SetTimeout(500)
4848
.ThrowOnElasticsearchServerExceptions());
4949
Assert.Throws<WebException>(async () => await client.RootNodeInfoAsync());
50+
}
51+
52+
[Test]
53+
public void ConnectionException_WithThrowingClient_Async_PreserveStacktrace()
54+
{
55+
var uri = ElasticsearchConfiguration.CreateBaseUri(9494);
56+
var client = new ElasticClient(new ConnectionSettings(uri)
57+
.SetTimeout(500)
58+
.ThrowOnElasticsearchServerExceptions());
59+
var exception = Assert.Throws<WebException>(async () => await client.RootNodeInfoAsync());
60+
61+
var elasticClientType = typeof (ElasticClient);
62+
Assert.That(exception.StackTrace, Is.Not.StringStarting(string.Format(" at {0}.{1}", elasticClientType.Namespace, elasticClientType.Name)));
5063
}
5164

5265
[Test]

0 commit comments

Comments
 (0)