Skip to content

Commit 8a45c86

Browse files
committed
fix exception handling
1 parent 45c7fd5 commit 8a45c86

1 file changed

Lines changed: 3 additions & 7 deletions

File tree

  • acp/src/commonMain/kotlin/com/agentclientprotocol/client

acp/src/commonMain/kotlin/com/agentclientprotocol/client/Client.kt

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -251,15 +251,11 @@ public class Client(
251251
if (sessionId != null) {
252252
// Session may have been closed between the elicitation and the completion;
253253
// per the RFD, ignore unknown/already-completed IDs gracefully
254+
255+
254256
val holder = _sessions.value.sessions[sessionId]
255257
if (holder != null && holder.session.isCompleted) {
256-
@Suppress("SwallowedException")
257-
val session = try {
258-
@OptIn(ExperimentalCoroutinesApi::class)
259-
holder.session.getCompleted()
260-
} catch (_: IllegalStateException) {
261-
null
262-
}
258+
val session = runCatching { getSessionOrThrow(sessionId) }.getOrNull()
263259
if (session != null) {
264260
val ops = session.operations as? ElicitationOperations
265261
if (ops != null) {

0 commit comments

Comments
 (0)