From c207fca58ebf9d9495b009a45bf336a3c6d68e3b Mon Sep 17 00:00:00 2001 From: Ladd Hoffman Date: Wed, 20 Mar 2024 09:41:06 -0500 Subject: [PATCH] backend error message logging --- backend/index.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/backend/index.js b/backend/index.js index 949a8af..de947ce 100644 --- a/backend/index.js +++ b/backend/index.js @@ -29,7 +29,14 @@ app.post('/write', async (req, res) => { app.get('/read/:hash', async (req, res) => { // Fetch content const { hash } = req.params; - const data = await db.get(req.params.hash); + let data; + try { + data = await db.get(req.params.hash); + } catch (e) { + console.log('read error:', e.message, hash); + res.status(e.status).end(); + return; + } console.log('read', hash); // Return content res.json(data);