nonebot / aiocqhttp

A Python SDK with async I/O for CQHTTP (OneBot).
https://aiocqhttp.nonebot.dev
MIT License
280 stars 39 forks source link

'ActionFailed' object has no attribute 'retcode' #53

Closed Ice9Coffee closed 3 years ago

Ice9Coffee commented 3 years ago

问题描述 'ActionFailed' object has no attribute 'retcode'

复现方法

try:
    # something
except ActionFailed as e:
    logger.error(f'retcode={e.retcode}')

期望的行为 见文档

    """
    OneBot 已收到 API 请求,但执行失败。

    ```py
    except ActionFailed as e:
        if e.retcode > 0:
            pass  # error code returned by CQHTTP
        elif e.retcode < 0:
            pass  # error code returned by CoolQ
"""


**运行环境**
 - 操作系统:Debian 10
 - aiocqhttp 版本:1.4.0
 - Python 版本:3.8
Ice9Coffee commented 3 years ago

或许1.4.0的实现不再需要显式指定retcode,直接调用str也能达到同样的目的。 目前的文档与新版实现有冲突,更新文档 or 代码做向下兼容,我觉得都可以。

cleoold commented 3 years ago

you can create a pr to remove the docstring

Ice9Coffee commented 3 years ago

you can create a pr to remove the docstring

这段docstring存在蛮久了,而且在aiocqhttp的文档中也有,直接删掉对基于aiocqhttp<=1.3.0开发机器人的开发者是不负责任的行为。 向前兼容 或 提示开发者有不兼容的更改 才是更合理的做法吧。

stdrc commented 3 years ago

minor 版本号更新本来就不应该有不兼容的更改,这个当时 pr 合并得草率了(

cleoold commented 3 years ago

you can create a pr to remove the docstring

这段docstring存在蛮久了,而且在aiocqhttp的文档中也有,直接删掉对基于aiocqhttp<=1.3.0开发机器人的开发者是不负责任的行为。 向前兼容 或 提示开发者有不兼容的更改 才是更合理的做法吧。

這次修改在 changelog 中提到了。即使是文檔還提到她只能代表文檔過期了。實際表現以 changelog 中提到的修改為准。

stdrc commented 3 years ago

這次修改在 changelog 中提到了。

更新日志只说了“调整 ActionFailed 错误信息格式”,并没有说到不兼容

stdrc commented 3 years ago

Fixed by #55