From f0f4532a8f8d5dbdec4d27f635494b925752f43e Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Fri, 25 Sep 2020 19:08:47 -0400 Subject: better invoice error handling --- routes/invoices.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/routes/invoices.js b/routes/invoices.js index b70dcbbe..11d62eb6 100644 --- a/routes/invoices.js +++ b/routes/invoices.js @@ -15,6 +15,7 @@ app.get("/invoice", auth, ah(async (req, res, next) => { })); app.post("/invoice", ah(async (req, res, next) => { + try { let { invoice, user } = req.body; if (!user) ({ user } = req); else { @@ -35,7 +36,6 @@ app.post("/invoice", ah(async (req, res, next) => { invoice.amount, invoice.tip, invoice.currency, - invoice.rate.toFixed(2) ); if (invoice.network === "liquid") { @@ -60,4 +60,8 @@ app.post("/invoice", ah(async (req, res, next) => { addresses[invoice.address] = user.username; if (invoice.unconfidential) addresses[invoice.unconfidential] = user.username; res.send(invoice); + } catch(e) { + l.error(e.message, e.stack); + res.status(500).send(`Problem during invoice creation: ${e.message}`); + } })); -- cgit v1.2.3