Skip to content

Commit

Permalink
Use proper exception subclass for invalid constraints error
Browse files Browse the repository at this point in the history
Signed-off-by: Keshav Priyadarshi <[email protected]>
  • Loading branch information
keshav-space committed Sep 11, 2023
1 parent 2f2c21a commit 5d41a29
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/univers/version_constraint.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,10 @@ def simplify_constraints(constraints):
return sorted(set(unequal_constraints + constraints))


class InvalidConstraintsError(Exception):
pass


def contains_version(version, constraints):
"""
Return True an assertion error if the ``constraints`` list contains the
Expand Down Expand Up @@ -539,7 +543,9 @@ def contains_version(version, constraints):

else:
# this should never happen as the constraints must be valid going in
raise Exception(f"Invalid constraints sequence: {constraints }")
raise InvalidConstraintsError(
f"Invalid comparator sequence: ('{cur_comp}', '{nxt_comp}') in {constraints!r}"
)

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

0 comments on commit 5d41a29

Please sign in to comment.