Skip to content

Commit bad23c1

Browse files
Catch RemoteRpcException, refactor Session.InvokeRpcAsync, remove unused using
Co-authored-by: SteveSandersonMS <1101362+SteveSandersonMS@users.noreply.github.com>
1 parent 63b974a commit bad23c1

3 files changed

Lines changed: 4 additions & 14 deletions

File tree

dotnet/src/Client.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -590,13 +590,13 @@ public async Task<List<SessionMetadata>> ListSessionsAsync(CancellationToken can
590590
return response.Sessions;
591591
}
592592

593-
private static async Task<T> InvokeRpcAsync<T>(JsonRpc rpc, string method, object?[]? args, CancellationToken cancellationToken)
593+
internal static async Task<T> InvokeRpcAsync<T>(JsonRpc rpc, string method, object?[]? args, CancellationToken cancellationToken)
594594
{
595595
try
596596
{
597597
return await rpc.InvokeWithCancellationAsync<T>(method, args, cancellationToken);
598598
}
599-
catch (StreamJsonRpc.RemoteInvocationException ex)
599+
catch (StreamJsonRpc.RemoteRpcException ex)
600600
{
601601
throw new IOException($"Communication error with Copilot CLI: {ex.Message}", ex);
602602
}

dotnet/src/Session.cs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,8 @@ internal CopilotSession(string sessionId, JsonRpc rpc, string? workspacePath = n
8080
WorkspacePath = workspacePath;
8181
}
8282

83-
private async Task<T> InvokeRpcAsync<T>(string method, object?[]? args, CancellationToken cancellationToken)
84-
{
85-
try
86-
{
87-
return await _rpc.InvokeWithCancellationAsync<T>(method, args, cancellationToken);
88-
}
89-
catch (StreamJsonRpc.RemoteInvocationException ex)
90-
{
91-
throw new IOException($"Communication error with Copilot CLI: {ex.Message}", ex);
92-
}
93-
}
83+
private Task<T> InvokeRpcAsync<T>(string method, object?[]? args, CancellationToken cancellationToken) =>
84+
CopilotClient.InvokeRpcAsync<T>(_rpc, method, args, cancellationToken);
9485

9586
/// <summary>
9687
/// Sends a message to the Copilot session and waits for the response.

dotnet/src/Types.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
* Copyright (c) Microsoft Corporation. All rights reserved.
33
*--------------------------------------------------------------------------------------------*/
44

5-
using System.IO;
65
using System.Text.Json;
76
using System.Text.Json.Serialization;
87
using Microsoft.Extensions.AI;

0 commit comments

Comments
 (0)