mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-02-17 16:20:05 +08:00
♿ improve actionfailed info
This commit is contained in:
parent
00305a8436
commit
83addf045f
@ -176,7 +176,7 @@ def _handle_api_result(result: Optional[Dict[str, Any]]) -> Any:
|
|||||||
"""
|
"""
|
||||||
if isinstance(result, dict):
|
if isinstance(result, dict):
|
||||||
if result.get("status") == "failed":
|
if result.get("status") == "failed":
|
||||||
raise ActionFailed(retcode=result.get("retcode"))
|
raise ActionFailed(**result)
|
||||||
return result.get("data")
|
return result.get("data")
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,12 +23,12 @@ class ActionFailed(BaseActionFailed, CQHTTPAdapterException):
|
|||||||
* ``retcode: Optional[int]``: 错误码
|
* ``retcode: Optional[int]``: 错误码
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, retcode: Optional[int] = None):
|
def __init__(self, **kwargs):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.retcode = retcode
|
self.info = kwargs
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return f"<ActionFailed retcode={self.retcode}>"
|
return f"<ActionFailed " + ", ".join(f"{k=}" for k in self.info) + ">"
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.__repr__()
|
return self.__repr__()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user