From 8b515e1cf638fba6c742d926fbf544e74ed59932 Mon Sep 17 00:00:00 2001 From: Alexis <35.alexis.pele@gmail.com> Date: Thu, 4 May 2023 18:20:13 +0200 Subject: [PATCH] Added error check if countryName isn't recognized --- index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/index.js b/index.js index 1d05a2d..d42f8b6 100644 --- a/index.js +++ b/index.js @@ -81,6 +81,10 @@ app.use('/rep', async (req, res) => { } } + if (!circoForeign) { + throw new Error('Error trying to parse this country : ' + countryName) + } + // If a code is found, send the associated file containing the representant data const repFile = readFileSync(join(__dirname, `public/reps/${lookupTable[circoForeign]}.json`), 'utf-8') res.end(repFile)