refactor: specify exception handling for network and protocol errors in openclaw_gateway.py

This commit is contained in:
Abhimanyu Saharan
2026-02-09 02:53:25 +05:30
parent 872ae09512
commit 50e3ff38b2

View File

@@ -8,6 +8,7 @@ from urllib.parse import urlencode, urlparse, urlunparse
from uuid import uuid4
import websockets
from websockets.exceptions import WebSocketException
from app.integrations.openclaw_gateway_protocol import PROTOCOL_VERSION
@@ -121,7 +122,13 @@ async def openclaw_call(
return await _send_request(ws, method, params)
except OpenClawGatewayError:
raise
except Exception as exc: # pragma: no cover - network errors
except (
asyncio.TimeoutError,
ConnectionError,
OSError,
ValueError,
WebSocketException,
) as exc: # pragma: no cover - network/protocol errors
raise OpenClawGatewayError(str(exc)) from exc