Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makes nice error message when Chrome isn't launched #121

Merged
merged 3 commits into from
Apr 4, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ lighthouse({
flags: cli.flags
}).then(results => {
Printer[cli.flags.json ? 'json' : 'prettyPrint'](log, console, url, results);
}).catch(err => {
if (err.code === 'ECONNREFUSED') {
console.error('Unable to connect to Chrome. Did you run ./launch-chrome.sh?');
} else {
console.error('Runtime error encountered:', err);
console.error(err.stack);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is an error, you should also set the exit code:

process.exitCode = 1;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think process.exit(1) would also set the exit status code to 1 as well. :)

process.exit(1);
});

if (cli.flags.verbose) {
Expand Down
7 changes: 1 addition & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,5 @@ module.exports = function(opts) {
return Gatherer
.gather(gatherers, {url, driver})
.then(artifacts => Auditor.audit(artifacts, audits))
.then(results => Aggregator.aggregate(aggregators, results))
.catch(function(err) {
console.log('error encountered', err);
console.log(err.stack);
throw err;
});
.then(results => Aggregator.aggregate(aggregators, results));
};