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: blacklight
GPG Key ID: D90FBA7F76362774
1 changed files with 3 additions and 0 deletions

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)