Skip to content

Commit

Permalink
Improve error message
Browse files Browse the repository at this point in the history
Signed-off-by: Elron Bandel <elron.bandel@ibm.com>
  • Loading branch information
elronbandel committed Mar 20, 2024
1 parent 230503a commit d8ee3e3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/unitxt/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,6 @@ def safe_eval(expression: str, context: dict, allowed_tokens: list) -> any:
allowd_sub_strings = list(context.keys()) + allowed_tokens
if is_made_of_sub_strings(expression, allowd_sub_strings):
return eval(expression, {"__builtins__": {}}, context)
raise ValueError(f"Unreocgnized Expression: {expression}")
raise ValueError(
f"The expression '{expression}' can not be evaluated because it contains tokens outside the allowed list of {allowd_sub_strings}."
)

0 comments on commit d8ee3e3

Please sign in to comment.