except timeout

This commit is contained in:
dni ⚡ 2025-03-31 17:35:54 +02:00 committed by Vlad Stan
parent f8f042a67b
commit 4ad463d3a8

View File

@ -7,7 +7,7 @@ from collections.abc import AsyncGenerator
from typing import Any, Optional from typing import Any, Optional
import httpx import httpx
from httpx import HTTPError from httpx import HTTPError, TimeoutException
from loguru import logger from loguru import logger
from websockets.client import connect from websockets.client import connect
@ -175,8 +175,13 @@ class PhoenixdWallet(Wallet):
timeout=40, timeout=40,
) )
r.raise_for_status() r.raise_for_status()
except TimeoutException:
# be safe and return pending on timeouts
msg = f"Timeout connecting to {self.endpoint}."
logger.error(msg)
return PaymentResponse(ok=None, error_message=msg)
except HTTPError as exc: except HTTPError as exc:
# HTTPError includes all 4xx and 5xx responses and timeout, # HTTPError includes all 4xx and 5xx responses
msg = f"Unable to connect to {self.endpoint}." msg = f"Unable to connect to {self.endpoint}."
logger.error(msg) logger.error(msg)
logger.error(exc) logger.error(exc)