-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add specific error handling for client connect #64
base: main
Are you sure you want to change the base?
Add specific error handling for client connect #64
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @SeanChinJunKai, thanks for the PR. Could you please add a test for your change?
Hi @e5l, I will be adding unit tests, was taking some time to learn more about cancellation exceptions |
Hi @e5l, I have added one unit test to test for non-CancellationException. Could I check how CancellationException will be thrown from within the connect function? Based on CancellationException documents: Thrown by cancellable suspending functions if the coroutine is cancelled while it is suspended. It indicates normal cancellation of a coroutine. I am not too sure if the CancellationException will be thrown in the connect function |
src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/client/Client.kt
Outdated
Show resolved
Hide resolved
@Test | ||
fun `should reject due to non cancellation exception`() = runTest { | ||
var closed = false | ||
val clientTransport = object : AbstractTransport() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see clientTransport
is very similar to the one in the previous test. should we create a test utility?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i will look into this
@@ -189,6 +191,61 @@ class ClientTest { | |||
assertTrue(closed) | |||
} | |||
|
|||
@Test | |||
fun `should reject due to non cancellation exception`() = runTest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add test for the case when a Cancellation exception is thrown?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ribhavpahuja can i ask how will cancellation exception be thrown in this case? wanted to clarify before adding a test
Hi @e5l, could you review this PR please? I have added test for this change |
Resolves #20
Motivation and Context
How Has This Been Tested?
Unit Tested
Breaking Changes
No
Types of changes
Checklist