Skip to content

Commit

Permalink
improve error message when parentheses cannot be found in descriptor
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoerg committed Oct 26, 2023
1 parent 70ffb2b commit dab0c11
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions hwilib/descriptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,9 +432,12 @@ def _get_func_expr(s: str) -> Tuple[str, str]:
:return: The function name as the first element of the tuple, and the expression contained within the function as the second element
:raises: ValueError: if a matching pair of parentheses cannot be found
"""
start = s.index("(")
end = s.rindex(")")
return s[0:start], s[start + 1:end]
try:
start = s.index("(")
end = s.rindex(")")
return s[0:start], s[start + 1:end]
except ValueError:
raise ValueError("A matching pair of parentheses cannot be found")


def _get_const(s: str, const: str) -> str:
Expand Down

0 comments on commit dab0c11

Please sign in to comment.