Skip to content

Commit

Permalink
Merge pull request levexis#14 from ryankinal/master
Browse files Browse the repository at this point in the history
Added error handling to function startPhantom. Closes levexis#13
  • Loading branch information
Paul Cook committed Nov 12, 2014
2 parents c4b6efc + c885cb2 commit 933f68d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tasks/selenium_webdriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ function startPhantom ( next, options ) {
phantomProcess.stdout.setEncoding('utf8');
// wait for client ready message before proceeding
phantomProcess.stdout.on('data', function( msg ) {
var error;
// look for msg that indicates it's ready and then stop logging messages
if ( !started && msg.indexOf( 'Registered with grid' ) > -1) {
console.log ('registered phantomjs with hub running on ' + options.host + ':' + options.port);
Expand All @@ -95,6 +96,10 @@ function startPhantom ( next, options ) {
if (typeof next === 'function') {
return next();
}
} else if (msg.indexOf('ERROR') > -1) {
error = JSON.parse(msg.substring(msg.indexOf('{')));
console.trace(error);
process.exit(1);
}
});
}
Expand Down

0 comments on commit 933f68d

Please sign in to comment.