feat: handle cli errors/timeout (#250)

pull/251/head
Adam Pash 5 years ago committed by GitHub
parent 44edcda53f
commit b77a236dbe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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);

Loading…
Cancel
Save