-
-
Notifications
You must be signed in to change notification settings - Fork 43
Detect if the login fails and throw appropriate exception #51
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
base: master
Are you sure you want to change the base?
Detect if the login fails and throw appropriate exception #51
Conversation
|
Thank you! i agree that this is something that should be addressed because the current messages are not clear. While reviewing i found |
11f04bf to
797e531
Compare
|
I hadn't noticed I've updated the PR to use it (forced pushed). I've noticed Growatt have updated their WAF to block the default User Agent, so I think it makes sense to add a specific GrowattAPI exception for that. I've proposed Also updated the PR to detect |
|
Is it okay if i implement the raise_for_status, and think about the other exceptions a little longer? I'm afraid of losing context for the developer using it instead of gaining it. I think the raise_for_status will not cause a breaking change (If it will not raise a http exception it will raise a json decode exception) but the check for success will |
I really like this approach @indykoning - Good catch on the Home Assistant implementation. I think throwing the exception for users of the library to handle is a really good idea. It should also mean that we can handle the scenarios when the servers are unavailable in a more consistent manner as well. |
… is incorrect Throw GrowattApiUserAgentBlockedException if User Agent is being blocked (HTTP 403 error) Throw requests.exceptions.HTTPError for other API HTTP errors Throw GrowattApiUnknownException for unknown JSON response errors
797e531 to
f46f7ee
Compare
|
@indykoning Could you implement the basic |
|
If I understand correctly raising exceptions was already implemented in 1.3.1 and this PR should be closed: 667a520 |
PR to detect if a login 403 error and throw a more obvious exception message than a JSON decode error.
Helps address issue #49