Display try catch refactor (#704)
* Remove try-catch from _termLookup Already handled by _onTermLookup * Move try-catch out of _onTermLookup and into _onGlossaryMouseUp
This commit is contained in:
parent
f271c83d77
commit
a562a11498
@ -521,12 +521,15 @@ class Display extends EventDispatcher {
|
||||
|
||||
_onGlossaryMouseUp(e) {
|
||||
if (!this._clickScanPrevent && DOM.isMouseButtonPressed(e, 'primary')) {
|
||||
try {
|
||||
this._onTermLookup(e);
|
||||
} catch (error) {
|
||||
this.onError(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async _onTermLookup(e) {
|
||||
try {
|
||||
if (!this._historyHasState()) { return; }
|
||||
|
||||
const termLookupResults = await this._termLookup(e);
|
||||
@ -560,13 +563,9 @@ class Display extends EventDispatcher {
|
||||
}
|
||||
};
|
||||
this.setContent(details);
|
||||
} catch (error) {
|
||||
this.onError(error);
|
||||
}
|
||||
}
|
||||
|
||||
async _termLookup(e) {
|
||||
try {
|
||||
e.preventDefault();
|
||||
|
||||
const {length: scanLength, deepDomScan: deepScan, layoutAwareScan} = this._options.scanning;
|
||||
@ -590,9 +589,6 @@ class Display extends EventDispatcher {
|
||||
}
|
||||
|
||||
return {textSource, definitions};
|
||||
} catch (error) {
|
||||
this.onError(error);
|
||||
}
|
||||
}
|
||||
|
||||
_onAudioPlay(e) {
|
||||
|
Loading…
Reference in New Issue
Block a user