Skip to content
This repository has been archived by the owner on Feb 26, 2021. It is now read-only.

Commit

Permalink
Fix #311, show a proper error when Reader Mode fails
Browse files Browse the repository at this point in the history
  • Loading branch information
ianb committed Sep 27, 2019
1 parent 345b9bc commit b9d0bd8
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion extension/intents/read/read.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,19 @@ this.intents.read = (function() {
`,
async run(desc) {
// FIXME: this can fail, we should guard against that and show error:
await browser.tabs.toggleReaderMode();
try {
await browser.tabs.toggleReaderMode();
} catch (e) {
if (
e.message &&
e.message.includes(
"The specified tab cannot be placed into reader mode"
)
) {
e.displayMessage = "This page cannot be put into Reader Mode";
}
throw e;
}
// FIXME: toggleReaderMode just returns immediately so we have to wait to get this to work
// Ideally it would give an error or something if it was attached to the wrong kind of tab
await util.sleep(1000);
Expand Down

0 comments on commit b9d0bd8

Please sign in to comment.