Skip to content

Commit 2544c9c

Browse files
Swap generic Exception for ValidationError
1 parent f1a964c commit 2544c9c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/mcp/shared/session.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import anyio
99
import httpx
1010
from anyio.streams.memory import MemoryObjectReceiveStream, MemoryObjectSendStream
11-
from pydantic import BaseModel
11+
from pydantic import BaseModel, ValidationError
1212
from typing_extensions import Self
1313

1414
from mcp.shared.exceptions import McpError
@@ -357,7 +357,7 @@ async def _receive_loop(self) -> None:
357357
by_alias=True, mode="json", exclude_none=True
358358
)
359359
)
360-
except Exception as e:
360+
except ValidationError as e:
361361
# For other validation errors, log and continue
362362
logging.warning(
363363
"Failed to validate request: %s. Message was: %s",
@@ -389,7 +389,7 @@ async def _receive_loop(self) -> None:
389389
by_alias=True, mode="json", exclude_none=True
390390
)
391391
)
392-
except Exception as e:
392+
except ValidationError as e:
393393
# For other validation errors, log and continue
394394
logging.warning(
395395
"Failed to validate notification: %s. Message was: %s",

0 commit comments

Comments
 (0)