mirror of
https://github.com/postmanlabs/openapi-to-postman.git
synced 2022-11-29 22:05:00 +03:00
removed unwanted try catch
This commit is contained in:
52
index.js
52
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) {
|
||||
|
||||
Reference in New Issue
Block a user