feat(message.py): raise ValueError if invalid json in Message.from_bytes()

This commit is contained in:
2025-09-21 21:59:12 +02:00
parent 9b5b104061
commit bc1bf46388

View File

@@ -87,7 +87,12 @@ class Message:
Returns:
Message: The created message.
"""
return cls.from_dict(json.loads(data))
try:
json_data = json.loads(data)
except json.JSONDecodeError as e:
raise ValueError("Invalid JSON data") from e
return cls.from_dict(json_data)
@classmethod
def from_bytes(cls, data: bytes) -> Message: