Skip to content

Commit e4a3538

Browse files
committed
Improve error messages for strings (#74)
1 parent 341ae08 commit e4a3538

File tree

1 file changed

+4
-4
lines changed
  • aas_test_engines/test_cases/v3_0

1 file changed

+4
-4
lines changed

aas_test_engines/test_cases/v3_0/parse.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,20 +67,20 @@ def __init__(self, raw_value: str):
6767
self.raw_value = raw_value
6868
if self.min_length is not None:
6969
if len(raw_value) < self.min_length:
70-
raise ValueError("String is too short")
70+
raise ValueError(f"String is shorter than {self.min_length} characters")
7171
if self.max_length is not None:
7272
if len(raw_value) > self.max_length:
73-
raise ValueError("String is too long")
73+
raise ValueError(f"String is longer than {self.max_length} characters")
7474

7575
# Constraint AASd-130: An attribute with data type "string" shall be restricted to the characters as defined in
7676
# XML Schema 1.0, i.e. the string shall consist of these characters only: ^[\x09\x0A\x0D\x20-\uD7FF\uE000-
7777
# \uFFFD\u00010000-\u0010FFFF]*$.
7878
if re.fullmatch(r"[\x09\x0a\x0d\x20-\ud7ff\ue000-\ufffd\U00010000-\U0010ffff]*", raw_value) is None:
79-
raise ValueError("String is not XML serializable")
79+
raise ValueError("Constraint AASd-130 violated: String is not XML serializable")
8080

8181
if self.pattern:
8282
if re.fullmatch(self.pattern, raw_value) is None:
83-
raise ValueError("String does not match pattern")
83+
raise ValueError(f"String does not match pattern {self.pattern}")
8484

8585
def __eq__(self, other: "StringFormattedValue") -> bool:
8686
return self.raw_value == other.raw_value

0 commit comments

Comments
 (0)