Merge pull request #254 from tiqi-group/fix/serialize_exception

fix: serialize exception
This commit is contained in:
Mose Müller
2025-07-03 15:59:35 +02:00
committed by GitHub
2 changed files with 20 additions and 1 deletions

View File

@@ -158,7 +158,7 @@ class Serializer:
"doc": None, "doc": None,
"readonly": True, "readonly": True,
"type": "Exception", "type": "Exception",
"value": obj.args[0], "value": obj.args[0] if len(obj.args) > 0 else "",
"name": obj.__class__.__name__, "name": obj.__class__.__name__,
} }

View File

@@ -1225,3 +1225,22 @@ def test_add_prefix_to_full_access_path(
serialized_obj: SerializedObject, prefix: str, expected: SerializedObject serialized_obj: SerializedObject, prefix: str, expected: SerializedObject
) -> None: ) -> None:
assert add_prefix_to_full_access_path(serialized_obj, prefix) == expected assert add_prefix_to_full_access_path(serialized_obj, prefix) == expected
def test_serialize_exception() -> None:
assert dump(Exception()) == {
"doc": None,
"full_access_path": "",
"name": "Exception",
"readonly": True,
"type": "Exception",
"value": "",
}
assert dump(Exception("Exception message")) == {
"doc": None,
"full_access_path": "",
"name": "Exception",
"readonly": True,
"type": "Exception",
"value": "Exception message",
}