feat: adding try catch code

This commit is contained in:
carlos
2022-06-04 15:37:45 -04:00
parent 013cbc6346
commit c088e00645
4 changed files with 21 additions and 2 deletions

View File

@@ -1,7 +1,12 @@
const { readFile } = require('./utils/converter')
const add = async (path) => {
return await readFile(`${path}`)
try {
if (typeof path !== 'string') throw new Error('path have to be an string')
return await readFile(`${path}`)
} catch (e) {
throw new Error(e.message)
}
}
module.exports = add