Skip to content

Commit f00348b

Browse files
committedJan 21, 2025
🐛 bug: 将HTTP异常处理更改为TimeoutException,并正确检查api的可用性
1 parent 90efcbe commit f00348b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed
 

‎nonebot_plugin_fishspeech_tts/on_start_up.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from httpx import AsyncClient, HTTPStatusError
1+
from httpx import AsyncClient, TimeoutException
22
from nonebot import get_driver
33
from nonebot.log import logger
44

@@ -16,6 +16,8 @@ async def check_online_api():
1616
async with AsyncClient() as client:
1717
try:
1818
response = await client.get(API)
19-
response.raise_for_status()
20-
except HTTPStatusError as e:
19+
rsp_text = response.text
20+
if "Nothing" in rsp_text:
21+
logger.warning("在线API可用")
22+
except TimeoutException as e:
2123
logger.warning(f"在线API不可用: {e}\n请尝试更换API地址或配置代理")

0 commit comments

Comments
 (0)
Failed to load comments.