Skip to content

Commit

Permalink
Improved error handling when starting webdriver fails
Browse files Browse the repository at this point in the history
  • Loading branch information
beatfactor committed Dec 1, 2018
1 parent efc5630 commit c3dfb16
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions bin/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ try {
});
});
} catch (err) {
err.message = 'An error occurred while trying to start the Nightwatch Runner: ' + err.message;
Logger.error(err);
process.exit(2);
}
2 changes: 1 addition & 1 deletion lib/runner/cli/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ class CliRunner {
}

return WebDriver.startInstances().catch(err => {
Logger.error(err.toString() + '\n');
Logger.error(err);

if (err.errorOut) {
Logger.error(err.errorOut);
Expand Down
10 changes: 9 additions & 1 deletion lib/runner/wd-instances/base-wd-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,15 @@ class BaseWDServer {
this.startTime = new Date();

this.setCliArgs();
this.createProcess();
try {
this.createProcess();
} catch (err) {
err.message = `Error while trying to create ${this.serviceName} process: ${err.message}.`;
err.detailedErr = 'For more info about Node.js errors see https://nodejs.org/api/errors.html';

return Promise.reject(err);
}


this.process.stdout.on('data', this.onStdout.bind(this));
this.process.stderr.on('data', this.onStderr.bind(this));
Expand Down
2 changes: 1 addition & 1 deletion lib/runner/wd-instances/chromedriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ChromeDriver extends BaseWDServer {
}

get serviceName() {
return 'ChromeDriver';
return ChromeDriver.serviceName;
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/runner/wd-instances/geckodriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class GeckoDriver extends BaseWDServer {
}

get serviceName() {
return 'GeckoDriver';
return GeckoDriver.serviceName;
}

get serviceDownloadUrl() {
Expand Down
2 changes: 1 addition & 1 deletion lib/runner/wd-instances/safaridriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class SafariDriver extends BaseWDServer {
}

get serviceName() {
return 'SafariDriver';
return SafariDriver.serviceName;
}

constructor(settings) {
Expand Down

0 comments on commit c3dfb16

Please sign in to comment.