Skip to content
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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

SeanChinJunKai
Copy link

Resolves #20

Motivation and Context

  • Enhancement to add specific error handling for Client.connect

How Has This Been Tested?

Unit Tested

Breaking Changes

No

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

@e5l e5l self-requested a review March 31, 2025 16:08
Copy link
Contributor

@e5l e5l left a 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?

@SeanChinJunKai
Copy link
Author

Hi @e5l, I will be adding unit tests, was taking some time to learn more about cancellation exceptions

@SeanChinJunKai SeanChinJunKai marked this pull request as ready for review April 1, 2025 08:02
@SeanChinJunKai
Copy link
Author

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

@SeanChinJunKai SeanChinJunKai changed the title feat: add specific error handling for client connect Add specific error handling for client connect Apr 2, 2025
@Test
fun `should reject due to non cancellation exception`() = runTest {
var closed = false
val clientTransport = object : AbstractTransport() {

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?

Copy link
Author

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 {

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?

Copy link
Author

@SeanChinJunKai SeanChinJunKai Apr 6, 2025

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

@SeanChinJunKai
Copy link
Author

Hi @e5l, could you review this PR please? I have added test for this change

@e5l e5l self-requested a review April 7, 2025 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider handling specific exception in the Client.connect
3 participants