Fix error handling for screenshot captures (#777)
This commit is contained in:
parent
44f38c4dea
commit
b28241dbf2
@ -537,8 +537,15 @@ class Backend {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const windowId = sender.tab.windowId;
|
const windowId = sender.tab.windowId;
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve, reject) => {
|
||||||
chrome.tabs.captureVisibleTab(windowId, options, (dataUrl) => resolve(dataUrl));
|
chrome.tabs.captureVisibleTab(windowId, options, (dataUrl) => {
|
||||||
|
const e = chrome.runtime.lastError;
|
||||||
|
if (e) {
|
||||||
|
reject(new Error(e.message));
|
||||||
|
} else {
|
||||||
|
resolve(dataUrl);
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1049,9 +1049,11 @@ class Display extends EventDispatcher {
|
|||||||
|
|
||||||
const details = {};
|
const details = {};
|
||||||
if (this._noteUsesScreenshot(mode)) {
|
if (this._noteUsesScreenshot(mode)) {
|
||||||
const screenshot = await this._getScreenshot();
|
try {
|
||||||
if (screenshot) {
|
const screenshot = await this._getScreenshot();
|
||||||
details.screenshot = screenshot;
|
details.screenshot = screenshot;
|
||||||
|
} catch (e) {
|
||||||
|
// NOP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1155,7 +1157,6 @@ class Display extends EventDispatcher {
|
|||||||
|
|
||||||
const {format, quality} = this._options.anki.screenshot;
|
const {format, quality} = this._options.anki.screenshot;
|
||||||
const dataUrl = await api.screenshotGet({format, quality});
|
const dataUrl = await api.screenshotGet({format, quality});
|
||||||
if (!dataUrl || dataUrl.error) { return; }
|
|
||||||
|
|
||||||
return {dataUrl, format};
|
return {dataUrl, format};
|
||||||
} finally {
|
} finally {
|
||||||
|
Loading…
Reference in New Issue
Block a user