Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: do not throw exception upon database warning #161

Merged
merged 3 commits into from
Feb 12, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions server/src/CouchClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ export default class CouchClient {
constructor(accessToken, dbName, dbUrl) {
this.accessToken = accessToken;
this.dbUrl = dbUrl || ApplicationConfig.instance().dbUrl();
if(dbName) {
if (dbName) {
this.dbName = dbName;
} else if(accessToken) {
} else if (accessToken) {
const userInfo = userDetails.getUser(accessToken);
if(userInfo) {
if (userInfo) {
this.dbName = userInfo.dbName;
}
}
Expand Down Expand Up @@ -66,7 +66,7 @@ export default class CouchClient {

async deleteDocument(documentId, revision) {
let rev = revision;
if(!rev) {
if (!rev) {
const doc = await this.getDocument(documentId);
rev = doc._rev;
}
Expand All @@ -85,10 +85,11 @@ export default class CouchClient {
async findDocuments(query, customHeaders = {}) {
const path = "/" + this.dbName + "/_find";
const response = await this.post(path, query, customHeaders);
if(response.warning) {
throw { "message": "No matching index found" }; //eslint-disable-line no-throw-literal
if (response.warning) {
CouchClient.logger().warn("CouchClient:: " + response.warning);
}
return response;

}

createIndex(indexDoc, customHeaders = {}) {
Expand Down