niwibe/py-couchdb — pull request #12 by flexd (2013-05-11 19:01:32+00:00)
Title: WIP: Error checking and refactor.

This is a bit WIP but I wanted your input!

It *should* work, but since the tests are not updated it might break somewhere.

I've tested db.save_bulk() and db.query() and they seem to work.

What this does is that I made a GenericError() exception, which we might want to rename to RequestError I suppose.

Whenever it gets an error doing a request it raises it, so we get things like

```python
raceback (most recent call last):
File "./test.py", line 23, in
db.save_bulk(a_list)
File "/home/kristoffer/.virtualenvs/eveapi/local/lib/python2.7/site-packages/pycouchdb/client.py", line 283, in save_bulk
(resp, results) = self.resource.post("_bulk_docs", data=data, params=params)
File "/home/kristoffer/.virtualenvs/eveapi/local/lib/python2.7/site-packages/pycouchdb/resource.py", line 70, in post
return self.request("POST", path, **kwargs)
File "/home/kristoffer/.virtualenvs/eveapi/local/lib/python2.7/site-packages/pycouchdb/resource.py", line 60, in request
raise GenericError(result)
pycouchdb.exceptions.GenericError: {u'reason': u'Document id must be a string', u'error': u'bad_request'}
```

Instead of just 'One or more documents were not saved'.

I think this is an improvement, but it still needs a bit of work :-)