Skip to content

Conversation

@glensc
Copy link
Contributor

@glensc glensc commented Jan 15, 2022

Many JSONDecodeError (from json module) are actually thrown because trakt.tv site responds with a status code that is not yet recognized by this library:

Add fallback logic to be able to catch this specific error from applications.

Fixes #146

trakt/core.py Outdated
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe should add a specific JsonDecodeException here?

trakt/errors.py Outdated
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

used negative code for internal errors sp the positive numbers could be mapped to HTTP status codes

trakt/core.py Outdated
Copy link
Contributor Author

@glensc glensc Jan 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or better add as constructor argument?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah. seems better design, so: 6de70a5 & a4106cd.

@glensc
Copy link
Contributor Author

glensc commented Jan 15, 2022

Another fresh error:

The specific exception would allow to figure out url and status code (.response property).

@glensc glensc force-pushed the BadResponseException branch from a4106cd to 0e92938 Compare January 15, 2022 20:04
@glensc
Copy link
Contributor Author

glensc commented Jan 23, 2022

yet another json decode error #194

@glensc glensc force-pushed the BadResponseException branch from 0e92938 to 27d90b1 Compare April 14, 2022 10:16
@almightiest
Copy link

This would be great to have, please merge, thank you!

glensc added a commit to glensc/python-pytrakt that referenced this pull request Oct 19, 2022
@glensc
Copy link
Contributor Author

glensc commented Oct 23, 2022

Carried:

@glensc glensc changed the title Feature: Throw BadResponseException on JSON decode errors [python-pytrakt] Feature: Throw BadResponseException on JSON decode errors Nov 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

trakt.init throws JSONDecodeError

2 participants