File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -548,6 +548,7 @@ def val_cardinality(self, new_value):
548
548
the maximum or an integer 2-tuple of the format '(min, max)'.
549
549
"""
550
550
invalid_input = False
551
+ exc_msg = "Can only assign positive single int or int-tuples of the format '(min, max)'"
551
552
552
553
# Empty values reset the cardinality to None.
553
554
if not new_value or new_value == (None , None ):
@@ -576,6 +577,10 @@ def val_cardinality(self, new_value):
576
577
577
578
else :
578
579
invalid_input = True
580
+
581
+ # Use helpful exception message in the following case:
582
+ if max_int and min_int and v_max < v_min :
583
+ exc_msg = "Minimum larger than maximum (min=%s, max=%s)" % (v_min , v_max )
579
584
else :
580
585
invalid_input = True
581
586
@@ -585,8 +590,7 @@ def val_cardinality(self, new_value):
585
590
for err in valid .errors :
586
591
print ("%s: %s" % (err .rank .capitalize (), err .msg ))
587
592
else :
588
- msg = "Can only assign single int or int-tuples of the format '(min, max)'"
589
- raise ValueError (msg )
593
+ raise ValueError (exc_msg )
590
594
591
595
def set_values_cardinality (self , min_val = None , max_val = None ):
592
596
"""
You can’t perform that action at this time.
0 commit comments