!25940 [Fallback] Provide error information when calling eval fails

Merge pull request !25940 from huangbingjian/update_eval_report
This commit is contained in:
i-robot 2021-11-09 02:34:08 +00:00 committed by Gitee
commit a24fba7795
1 changed files with 7 additions and 1 deletions

View File

@ -514,7 +514,13 @@ def eval_script(exp_str, params):
logger.debug(f"exp_str: '{exp_str}', params: '{params}'")
global_params = params[0]
local_params = params[1]
obj = eval(exp_str, global_params, local_params)
try:
obj = eval(exp_str, global_params, local_params)
except Exception as e:
error_info = f"When eval '{exp_str}' by using Fallback feature, an error occurred: " + str(e) + \
". You can try to turn off the Fallback feature by 'export ENV_SUPPORT_FALLBACK=0'."
logger.error(error_info)
raise e
if obj is None:
raise ValueError(f"When call 'eval', the result is none. exp_str: '{exp_str}'")
if isinstance(obj, set):