handle request errors

Eg. if the CouchDB server goes down, the request will get an error.