fix: chain exceptions in get_prompt and read_resource handlers (#2542)
This commit is contained in:
parent
2b0da5631a
commit
bf3e0010b8
1 changed files with 3 additions and 3 deletions
|
|
@ -447,8 +447,8 @@ class MCPServer(Generic[LifespanResultT]):
|
||||||
context = Context(mcp_server=self)
|
context = Context(mcp_server=self)
|
||||||
try:
|
try:
|
||||||
resource = await self._resource_manager.get_resource(uri, context)
|
resource = await self._resource_manager.get_resource(uri, context)
|
||||||
except ValueError:
|
except ValueError as exc:
|
||||||
raise ResourceError(f"Unknown resource: {uri}")
|
raise ResourceError(f"Unknown resource: {uri}") from exc
|
||||||
|
|
||||||
try:
|
try:
|
||||||
content = await resource.read()
|
content = await resource.read()
|
||||||
|
|
@ -1109,4 +1109,4 @@ class MCPServer(Generic[LifespanResultT]):
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.exception(f"Error getting prompt {name}")
|
logger.exception(f"Error getting prompt {name}")
|
||||||
raise ValueError(str(e))
|
raise ValueError(str(e)) from e
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue