Skip to content

Commit

Permalink
Added error handling to function startPhantom. Closes levexis#13
Browse files Browse the repository at this point in the history
  • Loading branch information
ryankinal committed Oct 28, 2014
1 parent c4b6efc commit c885cb2
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 c885cb2

Please sign in to comment.