From 968c85aab899995e468ae26fce93c96487b065c0 Mon Sep 17 00:00:00 2001 From: Konstantinos Bairaktaris Date: Tue, 21 Jun 2022 11:19:01 +0300 Subject: [PATCH] Fix Exception re-raising in models/events.py Exceptions do not have message attribute in Python 3. See [PEP-352](https://peps.python.org/pep-0352/) Also, and this is my opinion, it doesn't offer any value to re-raise the JSON decode error as something else. I would propose this change too: ```diff -try: - webhook_data = json.loads(json_data) -except (TypeError, ValueError) as ex: - raise Exception("The passed json_data is not JSON formatted . {}".format(str(ex))) +webhook_data = json.loads(json_data) ``` --- chargebee/models/event.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chargebee/models/event.py b/chargebee/models/event.py index f5196cb..bc992ac 100644 --- a/chargebee/models/event.py +++ b/chargebee/models/event.py @@ -22,7 +22,7 @@ def deserialize(json_data): try: webhook_data = json.loads(json_data) except (TypeError, ValueError) as ex: - raise Exception("The passed json_data is not JSON formatted . " + ex.message) + raise Exception("The passed json_data is not JSON formatted . {}".format(str(ex))) api_version = webhook_data.get('api_version', None) env_version = Environment.API_VERSION