From e17d52ae2acd361c244775cf9a3761bc3076776b Mon Sep 17 00:00:00 2001 From: Christopher Rose Date: Tue, 25 Jun 2019 23:18:36 +0530 Subject: [PATCH] Changes for errors --- index.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 33216e4..0f906a0 100644 --- a/index.js +++ b/index.js @@ -1,19 +1,20 @@ const {parseString} = require('xml2js') +const path = require('path') const fs = require('fs') -const settings = JSON.parse(fs.readFileSync("settings.json")) +const settings = JSON.parse(fs.readFileSync( path.join(__dirname,"settings.json") )) console.log("Loaded configuration") //console.log(settings) //console.log(process.argv) fs.readFile(settings.fileName,(err,data)=>{ if(err){ - throw new Error(err.code,": Could not read file. Try again.:",err.name) + throw new Error(`${err.code}: Could not read file. Try again. ${err.name}`) } console.log(`Reading ${settings.fileName}`) parseString(data,(err,res)=>{ if(err){ - throw new Error(err.code,": Error parsing file.:",err.name) + throw new Error(`${err.code}: Error parsing file. :${err.name}`) } console.log(`Parsing ${settings.fileName}`)