Skip to content

Commit 26862f8

Browse files
committed
Merge #711: improve error message when parentheses cannot be found in descriptor
dab0c11 improve error message when parentheses cannot be found in descriptor (Bruno Garcia) Pull request description: ACKs for top commit: achow101: ACK dab0c11 Tree-SHA512: d2cccb0998507262161cbd5aecf357fb83d809d099b5e4ff6d459d64a92c378e0cf48554a7a9390f59810135b86a6cf9065c5c6fd99d62b1a46bf04e2710d116
2 parents 2b600cd + dab0c11 commit 26862f8

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)