From 63afd90701a7d5db022252c902985efc414e07a4 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sat, 22 Jul 2023 15:14:05 +0200 Subject: [PATCH] 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. --- platypush/message/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/platypush/message/__init__.py b/platypush/message/__init__.py index 67c4efe696..480fb18239 100644 --- a/platypush/message/__init__.py +++ b/platypush/message/__init__.py @@ -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)