Skip to content

Commit

Permalink
Add error handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
bchrobot committed Jun 20, 2019
1 parent bf78be7 commit 834a6dd
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,14 @@ app.post(
"/twilio-message-report",
twilio.headerValidator(),
wrap(async (req, res) => {
await twilio.handleDeliveryReport(req.body);
const resp = new TwimlResponse();
res.writeHead(200, { "Content-Type": "text/xml" });
res.end(resp.toString());
try {
await twilio.handleDeliveryReport(req.body);
const resp = new TwimlResponse();
res.writeHead(200, { "Content-Type": "text/xml" });
return res.end(resp.toString());
} catch (exc) {
res.status(500).send(exc.message);
}
})
);

Expand Down

0 comments on commit 834a6dd

Please sign in to comment.