feat: adding try catch code
This commit is contained in:
7
index.js
7
index.js
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user