improve actionfailed info

This commit is contained in:
yanyongyu 2020-12-19 00:50:17 +08:00
parent 00305a8436
commit 83addf045f
2 changed files with 4 additions and 4 deletions

View File

@ -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")

View File

@ -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__()