mirror of
https://github.com/KimigaiiWuyi/GenshinUID.git
synced 2025-05-07 04:03:45 +08:00
🎨 优化API访问返回错误提示
This commit is contained in:
parent
52ad9bc67a
commit
a31ba8e457
@ -11,7 +11,7 @@ from abc import abstractmethod
|
||||
from string import digits, ascii_letters
|
||||
from typing import Any, Dict, List, Union, Literal, Optional, cast
|
||||
|
||||
from aiohttp import ClientSession
|
||||
from aiohttp import ClientSession, ContentTypeError
|
||||
|
||||
from .api import _API
|
||||
from .tools import (
|
||||
@ -845,7 +845,11 @@ class MysApi:
|
||||
proxy=self.proxy_url if use_proxy else None,
|
||||
timeout=300,
|
||||
) as resp:
|
||||
raw_data = await resp.json()
|
||||
try:
|
||||
raw_data = await resp.json()
|
||||
except ContentTypeError:
|
||||
_raw_data = await resp.text()
|
||||
raw_data = {'retcode': -999, 'data': _raw_data}
|
||||
print(raw_data)
|
||||
if 'retcode' in raw_data:
|
||||
retcode: int = raw_data['retcode']
|
||||
|
@ -33,5 +33,7 @@ def get_error(retcode: Union[int, str]) -> str:
|
||||
return '请求体出错, 请检查具体实现代码...'
|
||||
elif retcode == 10104:
|
||||
return CK_HINT
|
||||
elif retcode == -201:
|
||||
return '你的账号可能已被封禁, 请联系米游社客服...'
|
||||
else:
|
||||
return f'API报错, 错误码为{retcode}!'
|
||||
|
Loading…
x
Reference in New Issue
Block a user