milesrichardson / ParsePy

A relatively up-to-date fork of ParsePy, the Python wrapper for the Parse.com API. Originally maintained by @dgrtwo
MIT License
516 stars 184 forks source link

Expose HTTP code for non-400 errors #123

Open yuzeh opened 9 years ago

yuzeh commented 9 years ago

I've been using ParsePy and have seen stacktraces of the following form recently:

(rest of stack elided)
  File "/usr/local/lib/python2.7/dist-packages/parse_rest/query.py", line 37, in _fetch
    return [klass(**it) for it in klass.GET(uri, **kw).get('results')]
  File "/usr/local/lib/python2.7/dist-packages/parse_rest/connection.py", line 107, in GET
    return cls.execute(uri, 'GET', **kw)
  File "/usr/local/lib/python2.7/dist-packages/parse_rest/connection.py", line 101, in execute
    raise exc(e.read())
parse_rest.core.ParseError

Looks like the last entry comes from here:

https://github.com/dgrtwo/ParsePy/blob/9c5bd490e14f89e1b13d3b39b4dada3a7400e6c4/parse_rest/connection.py#L126

From my understanding, this means that the Parse server returned an error that isn't 400, 401, 403, or 404, with no message.

Since Parse isn't returning a message, I'm left in the dark about what kind of error this is, which is problematic for figuring out what to do. E.g it's a 5xx, I'd want to retry, but bubble up the exception if it's a 4xx.

If adding this information to ParseError makes sense, I'm happy to send over a pull request.