From 5d41a298bf43b693940daf4d96b2e84371ba4368 Mon Sep 17 00:00:00 2001 From: Keshav Priyadarshi Date: Tue, 12 Sep 2023 02:19:39 +0530 Subject: [PATCH] Use proper exception subclass for invalid constraints error Signed-off-by: Keshav Priyadarshi --- src/univers/version_constraint.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/univers/version_constraint.py b/src/univers/version_constraint.py index 1cc87552..4d80896a 100644 --- a/src/univers/version_constraint.py +++ b/src/univers/version_constraint.py @@ -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 @@ -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