增加自定义函数报错的异常处理

This commit is contained in:
zy7y 2021-03-12 10:48:12 +08:00 committed by Gitee
parent 7d973e4492
commit 3b3599b246
1 changed files with 5 additions and 2 deletions

View File

@ -45,8 +45,11 @@ def rep_expr(content: str, data: dict, expr: str = '&(.*?)&') -> str:
# 增加自定义函数得的调用函数写在tools/hooks.py中
for func in re.findall('@(.*?)@', content):
content = content.replace(f'@{func}@', exec_func(func))
try:
content = content.replace(f'@{func}@', exec_func(func))
except Exception as e:
logger.error(e)
continue
return content