Skip to content

Commit

Permalink
Handle exception thrown from api.
Browse files Browse the repository at this point in the history
  • Loading branch information
NivedhaSenthil committed Jul 16, 2018
1 parent 252c6ea commit acc7388
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions taiko.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,24 @@ function runFile(file) {
validate(file);
const realFuncs = {};
for (let func in taiko) {
realFuncs[func] = taiko[func];
if (realFuncs[func].constructor.name === 'AsyncFunction') global[func] = async function() {
const res = await realFuncs[func].apply(this, arguments);
if (res.description) {
res.description = symbols.pass + res.description;
console.log(removeQuotes(util.inspect(res.description, { colors: true }), res.description));
}
return res;
};
else global[func] = function() {
return realFuncs[func].apply(this, arguments);
};
require.cache[path.join(__dirname, 'taiko.js')].exports[func] = global[func];
try{
realFuncs[func] = taiko[func];
if (realFuncs[func].constructor.name === 'AsyncFunction') global[func] = async function() {
const res = await realFuncs[func].apply(this, arguments);
if (res.description) {
res.description = symbols.pass + res.description;
console.log(removeQuotes(util.inspect(res.description, { colors: true }), res.description));
}
return res;
};
else global[func] = function() {
return realFuncs[func].apply(this, arguments);
};
require.cache[path.join(__dirname, 'taiko.js')].exports[func] = global[func];
}
catch(e){
console.log(e);
}
}
const oldNodeModulesPaths = module.constructor._nodeModulePaths;
module.constructor._nodeModulePaths = function() {
Expand Down

0 comments on commit acc7388

Please sign in to comment.