Skip to content

Commit

Permalink
Fix unhandled exception (#541)
Browse files Browse the repository at this point in the history
* fix: UnhandledPromiseRejectionWarning: Unhandled promise rejection

* update
  • Loading branch information
yingwang-us committed Jul 31, 2020
1 parent c94b661 commit c348d71
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions app/mongo/mongoClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,14 @@ module.exports = class MongoClient {
const db = await this._clientConnect();
for(let i=0; i<viewsToCreate.length;i++){
let view = viewsToCreate[i];
let v=await db.createCollection(view.name, {viewOn: view.source, pipeline: view.pipeline, collation: view.options });
this.log.info(`Created new View ${view.name}`);
result.push(v);
try {
// catch the exception for views
let v=await db.createCollection(view.name, {viewOn: view.source, pipeline: view.pipeline, collation: view.options });
this.log.info(`Created new View ${view.name}`);
result.push(v);
} catch (e) {
this.log.warn(e);
}
}
return result;
}
Expand Down

0 comments on commit c348d71

Please sign in to comment.