Files
my-pal-mcp-server/tools/shared/exceptions.py
Fahad 95e69a7cb2 fix: improved error reporting; codex cli would at times fail to figure out how to handle plain-text / JSON errors
fix: working directory should exist, raise error and not try and create one
docs: improved API Lookup instructions
* test added to confirm failures
* chat schema more explicit about file paths
2025-10-17 23:42:32 +04:00

21 lines
721 B
Python

"""
Custom exceptions for Zen MCP tools.
These exceptions allow tools to signal protocol-level errors that should be surfaced
to MCP clients using the `isError` flag on `CallToolResult`. Raising one of these
exceptions ensures the low-level server adapter marks the result as an error while
preserving the structured payload we pass through the exception message.
"""
class ToolExecutionError(RuntimeError):
"""Raised to indicate a tool-level failure that must set `isError=True`."""
def __init__(self, payload: str):
"""
Args:
payload: Serialized error payload (typically JSON) to return to the client.
"""
super().__init__(payload)
self.payload = payload