Skip to content

Commit

Permalink
feat: handle cli errors/timeout (#250)
Browse files Browse the repository at this point in the history
  • Loading branch information
adampash authored Feb 6, 2019
1 parent 44edcda commit b77a236
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,23 @@ Usage:\n\
);
return;
}
const result = await Mercury.parse(urlToParse);
console.log(JSON.stringify(result, null, 2));
try {
const result = await Mercury.parse(urlToParse);
console.log(JSON.stringify(result, null, 2));
} catch (e) {
if (e.message === 'ETIMEDOUT' && false) {
console.error(
'\nMercury Parser encountered a timeout trying to load that resource.'
);
} else {
console.error(
'\nMercury Parser encountered a problem trying to parse that resource.\n'
);
console.error(e);
}
const reportBug =
'If you believe this was an error, please file an issue at:\n\n https://github.com/postlight/mercury-parser/issues/new';
console.error(`\n${reportBug}\n`);
process.exit(1);
}
})(url);

0 comments on commit b77a236

Please sign in to comment.