Skip to content

Commit

Permalink
Completely handle all unhandled promise in db
Browse files Browse the repository at this point in the history
  • Loading branch information
dungwinux committed Apr 1, 2019
1 parent 68aabe8 commit c80c42b
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 c80c42b

Please sign in to comment.