public T error(HttpResponse hr) { throw StdResponseHandler.createDbAccessException(hr); }
@Override public Boolean error(HttpResponse hr) { if(hr.getCode() == HttpStatus.NOT_FOUND) { // only 404 is a valid response, anything else is an error // see http://docs.couchdb.org/en/latest/api/database/common.html#head--db return false; } throw StdResponseHandler.createDbAccessException(hr); } @Override
@Override public Boolean error(HttpResponse hr) { if (hr.getCode() == HttpStatus.PRECONDITION_FAILED) { // 412 indicates existing database // see http://docs.couchdb.org/en/latest/api/database/common.html#put--db LOG.debug("database at db path {} already exists.", db.getPath()); return false; } throw StdResponseHandler.createDbAccessException(hr); } @Override
private HttpResponse handleRawResponse(HttpResponse hr) { try { if (!hr.isSuccessful()) { throw StdResponseHandler.createDbAccessException(hr); } return hr; } catch (Exception e) { hr.releaseConnection(); throw Exceptions.propagate(e); } } }