我正在制作一个自定义插件来查询数据库以获取用户信息以帮助客户支持。我的后端很闲。
每次我启动 bot 命令时,我都会受到欢迎:
Computer says nooo. See logs for details:
catching classes that do not inherit from BaseException is not allowed
我不确定这是否警告我我正在尝试在我的代码中捕获不是 BaseClass 的异常,或者是否引发了未知异常并在我的插件之外的其他地方捕获。
调试我试过:
try:
do_the_thing()
except (TypeError, ValueError) as e:
return('Something went wrong.')
我也试过:
try:
do_the_thing()
except Exception as e:
return('Something went wrong.')
而且我仍然得到errbot的警告。请注意,在 do_the_thing() 没有引发异常的情况下,该命令仍会运行并执行正确的操作。