Skip to content

datarobot_genai.drmcputils.client_exceptions

client_exceptions

Shared mapping from DataRobot SDK HTTP errors to :class:ToolError.

Lives in drmcputils so any drtools domain (predictive, files, panels, …) can depend on it without taking a dependency on a sibling domain.

raise_tool_error_for_client_error

raise_tool_error_for_client_error(exc: ClientError) -> NoReturn

Raise :class:ToolError from SDK text: 404 → NOT_FOUND, else UPSTREAM.

Source code in datarobot_genai/drmcputils/client_exceptions.py
def raise_tool_error_for_client_error(exc: ClientError) -> NoReturn:
    """Raise :class:`ToolError` from SDK text: 404 → ``NOT_FOUND``, else ``UPSTREAM``."""
    sc = getattr(exc, "status_code", None)
    msg = f"DataRobot API error ({sc}): {exc}"
    kind = ToolErrorKind.NOT_FOUND if sc == 404 else ToolErrorKind.UPSTREAM
    raise ToolError(msg, kind=kind) from exc