From 0190323d9525ceca17a232849df53320b1740c43 Mon Sep 17 00:00:00 2001 From: pavantejapotnuru Date: Mon, 1 Oct 2018 12:08:13 +0530 Subject: [PATCH] removed unwanted try catch --- index.js | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/index.js b/index.js index d73a6e9..1372b55 100644 --- a/index.js +++ b/index.js @@ -5,34 +5,34 @@ var convert = require('./lib/convert.js'), module.exports = { convert: function(input, options, cb) { - try { - if (input.type === 'string') { - return convert(input.data, options, cb); - } - else if (input.type === 'json') { - return convert(input.data, options, cb); - } - else if (input.type === 'file') { - return fs.readFile(input.data, 'utf8', function(err, data) { - if (err) { - return cb(err); - } - try { - return convert(JSON.parse(data), options, cb); - } - catch (e) { - return convert(data, options, cb); - } - }); - } - return cb(null, { - result: false, - reason: 'input type:' + input.type + ' is not valid' + // try { + if (input.type === 'string') { + return convert(input.data, options, cb); + } + else if (input.type === 'json') { + return convert(input.data, options, cb); + } + else if (input.type === 'file') { + return fs.readFile(input.data, 'utf8', function(err, data) { + if (err) { + return cb(err); + } + try { + return convert(JSON.parse(data), options, cb); + } + catch (e) { + return convert(data, options, cb); + } }); } - catch (e) { - return cb(e); - } + return cb(null, { + result: false, + reason: 'input type:' + input.type + ' is not valid' + }); + // } + // catch (e) { + // return cb(e); + // } }, validate: function(input) {