Skip to content
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

From the examples it is expected that obj['error'] is always set #25

Open
chpmrc opened this issue Sep 18, 2015 · 2 comments
Open

From the examples it is expected that obj['error'] is always set #25

chpmrc opened this issue Sep 18, 2015 · 2 comments

Comments

@chpmrc
Copy link

chpmrc commented Sep 18, 2015

Hi, thanks for this great library. I just wanted to report a behavior that, in my opinion, is not very obvious: in the examples it is shown that to check for errors it's enough to check whether obj['error'] is True. But when the request is successful the key 'error' is not set at all which might lead to a KeyError.

Is there a reason why obj['error'] is not set to False if the request is successful instead of not being set at all? I would expect this behavior for error_code not for just error.

Thank you.

@screeley
Copy link
Contributor

You might try using:

if 'error' in obj:

instead?

@chpmrc
Copy link
Author

chpmrc commented Sep 24, 2015

Yes and that would technically, not conceptually, solve the problem. What I'm trying to say is that a first-time user of the library might not expect this behavior. Maybe this is a common good practice or pattern (apologies in case).

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

No branches or pull requests

2 participants