forked from platypush/platypush
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:
parent
cef9d0e007
commit
63afd90701
1 changed files with 3 additions and 0 deletions
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in a new issue