Skip to content

Commit

Permalink
fix: Improve errors for roundtrip-unsafe values
Browse files Browse the repository at this point in the history
  • Loading branch information
Wuestengecko committed Jun 24, 2022
1 parent 044d7d2 commit 3fb7496
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions capellambse/loader/xmltools.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,16 @@ def __set__(self, obj, value) -> None:
try:
roundtripped = self.returntype(stringified)
except (TypeError, ValueError) as err:
raise TypeError(f"Value is not round-trip safe: {value}") from err
raise TypeError(
"Value is not round-trip safe:"
f" Cannot read back {stringified} as {value}"
) from err

if roundtripped != value:
raise TypeError(f"Value is not round-trip safe: {value}")
raise TypeError(
"Value is not round-trip safe:"
f"{value} would be read back as {roundtripped}"
)

xml_element.attrib[self.attribute] = stringified

Expand Down

0 comments on commit 3fb7496

Please sign in to comment.