diff options
| author | blasty <blasty@local> | 2026-07-24 14:41:23 +0200 |
|---|---|---|
| committer | blasty <blasty@local> | 2026-07-24 14:41:23 +0200 |
| commit | 0decb747ac9239faf5119b7faa80596995746ef9 (patch) | |
| tree | 7996725bc0d3c62d9c25d1f5bc3f12979711a52c /idatui/client.py | |
| parent | tests: pass url=""/db=None to IdaTui in the worker pilot path (diff) | |
| download | ida-tui-0decb747ac9239faf5119b7faa80596995746ef9.tar.gz ida-tui-0decb747ac9239faf5119b7faa80596995746ef9.tar.xz ida-tui-0decb747ac9239faf5119b7faa80596995746ef9.zip | |
refactor: extract shared error hierarchy + Session into idatui/errors.py
The IDAError/IDAConnectionError/IDAToolError/... exceptions and the Session
dataclass were defined in client.py (the ida-pro-mcp HTTP client), but the idalib
worker path (worker_client/domain/app) needs them without the HTTP transport.
Move them to a transport-agnostic errors.py; client.py re-exports them so the
deprecated mcp tooling and stress tests are unchanged (verified:
errors.IDAToolError IS client.IDAToolError, so cross-module `except` still works).
worker_client, domain (TYPE_CHECKING-guarded IDAClient hint), app, and __init__
now import the shared types from errors.py. This decouples the worker path from
client.py at runtime -- the prerequisite for deleting the mcp transport.
Diffstat (limited to 'idatui/client.py')
| -rw-r--r-- | idatui/client.py | 75 |
1 files changed, 13 insertions, 62 deletions
diff --git a/idatui/client.py b/idatui/client.py index f39a10d..2f74cbe 100644 --- a/idatui/client.py +++ b/idatui/client.py @@ -66,68 +66,19 @@ SESSION_AGNOSTIC_TOOLS = frozenset({"idb_list", "idb_open", "int_convert"}) _STALE_SESSION_MARKERS = ("session not found", "database is required") -# --------------------------------------------------------------------------- # -# Exceptions -# --------------------------------------------------------------------------- # -class IDAError(Exception): - """Base class for all client errors.""" - - -class IDAConnectionError(IDAError): - """The transport could not be established or was lost.""" - - -class IDATimeoutError(IDAError): - """A request exceeded its deadline.""" - - -class IDAProtocolError(IDAError): - """Malformed or unexpected HTTP / JSON-RPC framing.""" - - -class IDARPCError(IDAError): - """The JSON-RPC envelope carried an ``error`` object.""" - - def __init__(self, code: int, message: str, data: Any = None): - super().__init__(f"JSON-RPC error {code}: {message}") - self.code = code - self.message = message - self.data = data - - -class IDAToolError(IDAError): - """A tool call returned ``result.isError == true`` (a hard failure).""" - - def __init__(self, tool: str, message: str): - super().__init__(f"tool {tool!r} failed: {message}") - self.tool = tool - self.message = message - - -class IDASessionError(IDAError): - """No IDB session is open, or several are and none was pinned.""" - - -# --------------------------------------------------------------------------- # -# Session model -# --------------------------------------------------------------------------- # -@dataclass(frozen=True) -class Session: - session_id: str - filename: str - input_path: str - is_active: bool = False - is_analyzing: bool = False - - @classmethod - def from_dict(cls, d: dict) -> "Session": - return cls( - session_id=d.get("session_id", ""), - filename=d.get("filename", ""), - input_path=d.get("input_path", ""), - is_active=bool(d.get("is_active", False)), - is_analyzing=bool(d.get("is_analyzing", False)), - ) +# The error hierarchy and Session model now live in errors.py (transport- +# agnostic, shared with the idalib worker path); re-exported here so the +# deprecated mcp tooling and the stress tests keep importing them from client. +from .errors import ( # noqa: E402,F401 + IDAError, + IDAConnectionError, + IDATimeoutError, + IDAProtocolError, + IDARPCError, + IDAToolError, + IDASessionError, + Session, +) # --------------------------------------------------------------------------- # |
