-
-
Notifications
You must be signed in to change notification settings - Fork 28.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plex: Add exception handler when connection fails #8179
Plex: Add exception handler when connection fails #8179
Conversation
@abmantis, thanks for your PR! By analyzing the history of the files in this pull request, we identified @JesseWebDotCom, @fabaff and @tomduijf to be potential reviewers. |
@@ -145,6 +145,10 @@ def update_devices(): | |||
_LOGGER.error("Could not connect to plex server at http://%s", | |||
host) | |||
return | |||
except requests.exceptions.ConnectionError: | |||
_LOGGER.error("Could not connect to plex server at http://%s", | |||
host) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might want to consider catching RequestException, see http://docs.python-requests.org/en/latest/user/quickstart/#errors-and-exceptions .
Other than that, I'd recommend using except .. as:
except X as ex:
_LOGGER.error("asdf: %s" % ex)
to give a hint to the user about what type of error happened.
@@ -145,6 +145,10 @@ def update_devices(): | |||
_LOGGER.error("Could not connect to plex server at http://%s", | |||
host) | |||
return | |||
except requests.exceptions.RequestException as ex: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that you should remove the catching of OSError
, because that never happens.
Any plans to finish this PR? |
Yes. I'll probably be able to get back to this later today or tomorrow. |
8ee139a
to
1781538
Compare
Bueno 🐬 |
* add exception handler when connection fails * plex: improve exception handling * remove uneeded exception handler
Description:
Add exception handler for when the connection fails (server is down).
If the code does not interact with devices:
tox
run successfully. Your PR cannot be merged unless tests pass