Skip to content

Commit

Permalink
Merge pull request #73 from vnma0/72-fix
Browse files Browse the repository at this point in the history
Completely handle all unhandled promise in db
  • Loading branch information
dungwinux authored Apr 1, 2019
2 parents 68aabe8 + c80c42b commit 0ddd5bc
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/data/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,14 @@ function readSubmission(sub_id) {
reject(new Error(`Invalid Submission's ID: ${sub_id}`));
else
readUserByID(docs.user_id)
.then((res) => {
docs.username = res.username;
})
.then(
(res) => {
docs.username = res.username;
},
() => {
docs.username = null;
}
)
.finally(() => {
resolve(docs);
});
Expand Down Expand Up @@ -432,9 +437,14 @@ function readSubmissionSrc(sub_id) {
reject(new Error(`Invalid Submission's ID: ${sub_id}`));
else
readUserByID(docs.user_id)
.then((res) => {
docs.username = res.username;
})
.then(
(res) => {
docs.username = res.username;
},
() => {
docs.username = null;
}
)
.finally(() => {
resolve(docs);
});
Expand Down

0 comments on commit 0ddd5bc

Please sign in to comment.