Serialize exceptions in the default JSON serializers.

This allows us to easily pass errors in internal JSON payloads, and
ensure that these are serialized consistently across all the
integrations.
This commit is contained in:
Fabio Manganiello 2023-07-22 15:14:05 +02:00
parent cef9d0e007
commit 63afd90701
Signed by untrusted user: blacklight
GPG key ID: D90FBA7F76362774

View file

@ -78,6 +78,9 @@ class Message:
if isinstance(obj, Enum):
return obj.value
if isinstance(obj, Exception):
return f'<{obj.__class__.__name__}>' + (f' {obj}' if obj else '')
if is_dataclass(obj):
return asdict(obj)