Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix Exception re-raising in models/events.py#51

Open
kbairak wants to merge 1 commit into
chargebee:master from
kbairak:patch-1
Open

Fix Exception re-raising in models/events.py #51
kbairak wants to merge 1 commit into
chargebee:master from
kbairak:patch-1

Conversation

@kbairak

@kbairak kbairak commented Jun 21, 2022

Copy link
Copy Markdown

Exceptions do not have message attribute in Python 3.

See PEP-352

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:

-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)

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)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

AltStyle によって変換されたページ (->オリジナル) /