Skip to content

Commit efa6bf6

Browse files
committed
Use proper exception subclass for invalid constraints error
- fixes #123 Signed-off-by: Keshav Priyadarshi <git@keshav.space>
1 parent 2f2c21a commit efa6bf6

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/univers/version_constraint.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,10 @@ def simplify_constraints(constraints):
471471
return sorted(set(unequal_constraints + constraints))
472472

473473

474+
class InvalidConstraintsError(Exception):
475+
pass
476+
477+
474478
def contains_version(version, constraints):
475479
"""
476480
Return True an assertion error if the ``constraints`` list contains the
@@ -539,7 +543,10 @@ def contains_version(version, constraints):
539543

540544
else:
541545
# this should never happen as the constraints must be valid going in
542-
raise Exception(f"Invalid constraints sequence: {constraints }")
546+
raise InvalidConstraintsError(
547+
f"Invalid constraints sequence: ('{cur_comp} {cur_constraint.version}',"
548+
f"'{nxt_comp} {nxt_constraint.version}') in {constraints!r}"
549+
)
543550

544551
# If this is the last iteration and next comparator is ">" or >="
545552
# and the "tested version" is greater than the next version

0 commit comments

Comments
 (0)