Added error check if countryName isn't recognized
This commit is contained in:
4
index.js
4
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
|
// 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')
|
const repFile = readFileSync(join(__dirname, `public/reps/${lookupTable[circoForeign]}.json`), 'utf-8')
|
||||||
res.end(repFile)
|
res.end(repFile)
|
||||||
|
|||||||
Reference in New Issue
Block a user