catch command exception

This commit is contained in:
jxxghp 2024-05-19 08:35:18 +08:00
parent d2bcb197eb
commit 521b960364

View File

@ -201,10 +201,15 @@ class Command(metaclass=Singleton):
# 检查全局变量中是否存在
if class_name not in globals():
# 导入模块除了插件和Command本身只有chain能响应事件
try:
module = importlib.import_module(
f"app.chain.{class_name[:-5].lower()}"
)
class_obj = getattr(module, class_name)()
except Exception as e:
logger.error(f"事件处理出错:{str(e)} - {traceback.format_exc()}")
continue
else:
# 通过类名创建类实例
class_obj = globals()[class_name]()