Skip to content

Commit dab0c11

Browse files
committed
improve error message when parentheses cannot be found in descriptor
1 parent 70ffb2b commit dab0c11

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

hwilib/descriptor.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -432,9 +432,12 @@ def _get_func_expr(s: str) -> Tuple[str, str]:
432432
:return: The function name as the first element of the tuple, and the expression contained within the function as the second element
433433
:raises: ValueError: if a matching pair of parentheses cannot be found
434434
"""
435-
start = s.index("(")
436-
end = s.rindex(")")
437-
return s[0:start], s[start + 1:end]
435+
try:
436+
start = s.index("(")
437+
end = s.rindex(")")
438+
return s[0:start], s[start + 1:end]
439+
except ValueError:
440+
raise ValueError("A matching pair of parentheses cannot be found")
438441

439442

440443
def _get_const(s: str, const: str) -> str:

0 commit comments

Comments
 (0)