mirror of
https://github.com/nonebot/nonebot2.git
synced 2024-11-24 09:05:04 +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 result.get("status") == "failed":
|
||||
raise ActionFailed(retcode=result.get("retcode"))
|
||||
raise ActionFailed(**result)
|
||||
return result.get("data")
|
||||
|
||||
|
||||
|
@ -23,12 +23,12 @@ class ActionFailed(BaseActionFailed, CQHTTPAdapterException):
|
||||
* ``retcode: Optional[int]``: 错误码
|
||||
"""
|
||||
|
||||
def __init__(self, retcode: Optional[int] = None):
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__()
|
||||
self.retcode = retcode
|
||||
self.info = kwargs
|
||||
|
||||
def __repr__(self):
|
||||
return f"<ActionFailed retcode={self.retcode}>"
|
||||
return f"<ActionFailed " + ", ".join(f"{k=}" for k in self.info) + ">"
|
||||
|
||||
def __str__(self):
|
||||
return self.__repr__()
|
||||
|
Loading…
Reference in New Issue
Block a user