Skip to content

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

Open

Description

@elchiapp

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.

Activity

  1. screeley commented on Sep 23, 2015

    @screeley
    Contributor

    You might try using:

    if 'error' in obj:
    

    instead?

  2. elchiapp commented on Sep 24, 2015

    @elchiapp
    Author

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions