Consolidate McpClientException/McpServerException into McpException (#209)

This commit is contained in:
Stephen Toub 2025-04-03 21:10:57 -04:00 • committed by GitHub
commit 8fcdf95785
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 163 additions and 197 deletions

View file

@ -175,7 +175,7 @@ public class ClientIntegrationTests : LoggedTest, IClassFixture<ClientIntegratio
// act
await using var client = await _fixture.CreateClientAsync(clientId);
await Assert.ThrowsAsync<McpClientException>(() =>
await Assert.ThrowsAsync<McpException>(() =>
client.GetPromptAsync("non_existent_prompt", null, cancellationToken: TestContext.Current.CancellationToken));
}

View file

@ -217,7 +217,7 @@ public class McpServerBuilderExtensionsPromptsTests : LoggedTest, IAsyncDisposab
{
IMcpClient client = await CreateMcpClientForServer();
await Assert.ThrowsAsync<McpClientException>(async () => await client.GetPromptAsync(
await Assert.ThrowsAsync<McpException>(async () => await client.GetPromptAsync(
nameof(SimplePrompts.ThrowsException),
cancellationToken: TestContext.Current.CancellationToken));
}
@ -227,7 +227,7 @@ public class McpServerBuilderExtensionsPromptsTests : LoggedTest, IAsyncDisposab
{
IMcpClient client = await CreateMcpClientForServer();
var e = await Assert.ThrowsAsync<McpClientException>(async () => await client.GetPromptAsync(
var e = await Assert.ThrowsAsync<McpException>(async () => await client.GetPromptAsync(
"NotRegisteredPrompt",
cancellationToken: TestContext.Current.CancellationToken));
@ -239,7 +239,7 @@ public class McpServerBuilderExtensionsPromptsTests : LoggedTest, IAsyncDisposab
{
IMcpClient client = await CreateMcpClientForServer();
var e = await Assert.ThrowsAsync<McpClientException>(async () => await client.GetPromptAsync(
var e = await Assert.ThrowsAsync<McpException>(async () => await client.GetPromptAsync(
nameof(SimplePrompts.ReturnsChatMessages),
cancellationToken: TestContext.Current.CancellationToken));

View file

@ -435,7 +435,7 @@ public class McpServerBuilderExtensionsToolsTests : LoggedTest, IAsyncDisposable
{
IMcpClient client = await CreateMcpClientForServer();
var e = await Assert.ThrowsAsync<McpClientException>(async () => await client.CallToolAsync(
var e = await Assert.ThrowsAsync<McpException>(async () => await client.CallToolAsync(
"NotRegisteredTool",
cancellationToken: TestContext.Current.CancellationToken));

View file

@ -95,6 +95,6 @@ public class McpServerResourceTests
});
});
var sp = services.BuildServiceProvider();
Assert.Throws<McpServerException>(() => sp.GetRequiredService<IMcpServer>());
Assert.Throws<McpException>(() => sp.GetRequiredService<IMcpServer>());
}
}

View file

@ -95,7 +95,7 @@ public class McpServerTests : LoggedTest
}
[Fact]
public async Task RequestSamplingAsync_Should_Throw_McpServerException_If_Client_Does_Not_Support_Sampling()
public async Task RequestSamplingAsync_Should_Throw_McpException_If_Client_Does_Not_Support_Sampling()
{
// Arrange
await using var transport = new TestServerTransport();
@ -131,7 +131,7 @@ public class McpServerTests : LoggedTest
}
[Fact]
public async Task RequestRootsAsync_Should_Throw_McpServerException_If_Client_Does_Not_Support_Roots()
public async Task RequestRootsAsync_Should_Throw_McpException_If_Client_Does_Not_Support_Roots()
{
// Arrange
await using var transport = new TestServerTransport();
@ -523,7 +523,7 @@ public class McpServerTests : LoggedTest
await using var transport = new TestServerTransport();
var options = CreateOptions(serverCapabilities);
Assert.Throws<McpServerException>(() => McpServerFactory.Create(transport, options, LoggerFactory));
Assert.Throws<McpException>(() => McpServerFactory.Create(transport, options, LoggerFactory));
}
[Fact]

View file

@ -209,7 +209,7 @@ public class SseServerIntegrationTests : LoggedTest, IClassFixture<SseServerInte
// act
await using var client = await GetClientAsync();
await Assert.ThrowsAsync<McpClientException>(() =>
await Assert.ThrowsAsync<McpException>(() =>
client.GetPromptAsync("non_existent_prompt", null, cancellationToken: TestContext.Current.CancellationToken));
}