def handleCouchException(cmd, e): try: message = json.loads(e.message) cmd.stderr.write("CouchDB error: %s\n" % message['reason']) return 3 except: raise
def errback(failure, cmd): from twisted.web import error failure.trap(error.Error) cmd.stderr.write('ERROR: CouchDB returned an error with code %s\n' % failure.value.status) try: body = json.loads(failure.value.message) for key, value in body.items(): cmd.stderr.write(' - %s: %s\n' % (key, value)) return except: pass # from twisted.web import http # if failure.value.status == http.NOT_FOUND: return failure