From c885cb262e1d9ac361653e6b6c488e4e3525d78e Mon Sep 17 00:00:00 2001 From: Ryan Kinal Date: Tue, 28 Oct 2014 11:57:42 -0400 Subject: [PATCH] Added error handling to function startPhantom. Closes #13 --- tasks/selenium_webdriver.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tasks/selenium_webdriver.js b/tasks/selenium_webdriver.js index 015b3fd..8cee287 100644 --- a/tasks/selenium_webdriver.js +++ b/tasks/selenium_webdriver.js @@ -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); @@ -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); } }); }