Skip to content

Commit acbc402

Browse files
committed
Consistent error handling
1 parent fe23fe6 commit acbc402

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/routes/api/index.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,15 @@ indexRoute.post(
99
res: Response<ResponseBody>
1010
) => {
1111
const { event_type: eventType, repo } = req.query;
12-
if (!eventType) {
13-
return res.status(400).send('event_type param missing');
14-
}
15-
if (!repo) {
16-
return res.status(400).send('repo param missing');
12+
try {
13+
if (!eventType) {
14+
throw new Error('event_type param missing');
15+
}
16+
if (!repo) {
17+
throw new Error('repo param missing');
18+
}
19+
} catch (e) {
20+
return res.status(400).send(e.message);
1721
}
1822

1923
try {

0 commit comments

Comments
 (0)