Skip to content

Commit 66818b1

Browse files
committed
Remove unneeded try-catch blocks
1 parent 171b24b commit 66818b1

File tree

2 files changed

+9
-18
lines changed

2 files changed

+9
-18
lines changed

server/src/question/create.js

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,14 @@ export default (app) => {
2424
}
2525

2626
// save new question
27-
try {
28-
const question = new Question({
29-
text,
30-
expirationDate: moment(expirationDate).toDate(),
31-
owner: req.user.id,
32-
});
33-
await question.save();
27+
const question = new Question({
28+
text,
29+
expirationDate: moment(expirationDate).toDate(),
30+
owner: req.user.id,
31+
});
32+
await question.save();
3433

35-
// send created question back
36-
res.send(question);
37-
} catch (e) {
38-
res.stats(400).send({error: e.toString()});
39-
}
34+
// send created question back
35+
res.send(question);
4036
}));
4137
};

server/src/user/update.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,7 @@ export default (app) => {
6060
user.password = hash(password);
6161
}
6262
// try to save
63-
try {
64-
await user.save();
65-
} catch (e) {
66-
res.status(400).send({error: e.toString()});
67-
return;
68-
}
63+
await user.save();
6964

7065
// send succcess
7166
delete user.password;

0 commit comments

Comments
 (0)