INNER CODE UNIT · Python

_format_http_error

codedpro/mt5-trade-split-manager · mcp_server.py:43

def _format_http_error(resp: httpx.Response):
    """Turn a >=400 response into a readable string, preferring the bridge's
    own error detail (FastAPI puts it under "detail")."""
    try:
        body = resp.json()
    except Exception:
        return f"bridge returned HTTP {resp.status_code}: {resp.text}"
    detail = body.get("detail", body) if isinstance(body, dict) else body
    return f"bridge returned HTTP {resp.status_code}: {detail}"


def _request(method: str, path: str, json_body: Optional[dict] = None):
    """Call the REST bridge and return parsed JSON, or a readable error string.
    All httpx failures are caught here so tools never leak a traceback."""
    try:
        resp = httpx.request(
            method,
            f"{BRIDGE_URL}{path}",

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…