/*
*
* A simple script to create (or print) a JSON file from an XML file
*
*/

var fs = require('fs');
var path = require('path');
var xml2js = require('xml2js');
var parser = new xml2js.Parser();

var output = './';

module.exports = (function () {

    this.publishJSON = function (file, outputDir) {
        parser.parseString(file, function (err, result) {
            if (err) throw err;
            var outputFilename = outputDir + file.split(".xml")[0] + '.json';
            fs.writeFile(outputFilename, JSON.stringify(result, null, 4), function (err) {
                if (err) throw err
                console.log("JSON saved to " + outputFilename);
            });
        });
    }

    this.convertToJSON = function (file, callBack) {
        fs.readFile(file, 'utf-8', function (err, xml) {
            if (err) console.log(err)
            try {
              parser.parseString(xml, function (err, result) {
                  if (err) callBack("Error!");
                  else callBack({"result": result, "file": file});
              });
            }
            catch (err) {
                callBack("Error!");
            }
        });
    }

    this.convertToJSONSync = function (file) {
        fs.readFile(file, 'utf-8', function (err, xml) {
            if (err) console.log(err)
            parser.parseString(xml, function (err, result) {
                if (err);
                else return {"result": result, "file": file};
            });
        });
    }

    return this;
})();

@@ -841,28 +841,8 @@
 rr)%0A
-            try %7B%0A  
     
@@ -904,36 +904,32 @@
 %7B%0A              
-   
- 
 if (err) callBac
@@ -933,36 +933,32 @@
 Back(%22Error!%22);%0A
-    
               el
@@ -1000,26 +1000,24 @@
 e%22: file%7D);%0A
-  
             
@@ -1024,98 +1024,8 @@
 %7D);%0A
-            %7D%0A            catch (err) %7B%0A                callBack(%22Error!%22);%0A            %7D%0A
     

Remove try/catch