change(web): apply focused try-catch suggestion from review

Co-authored-by: Marc Durdin <marc@durdin.net>
This commit is contained in:
Joshua Horton 2025-02-24 09:15:50 +07:00 committed by GitHub
parent a5c987116b
commit accdb3752e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -42,10 +42,16 @@ export class LanguageProcessor extends EventEmitter<LanguageProcessorEventMap> {
return;
}
let instance: <TypeHere>;
try {
this.lmEngine = new LMLayer(capabilities, predictiveWorkerFactory?.constructInstance());
} catch {
instance = predictiveWorkerFactory?.constructInstance();
} catch(e) {
// We can condition on `lmEngine` being null/undefined.
console.warn('Web workers are not available: ' + (e ?? '').toString());
instance = null;
}
if(instance) {
this.lmEngine = new LMLayer(capabilities, instance);
}
}