Put in console.errors on extension initialization.

This commit is contained in:
Tamius Han 2021-04-12 20:54:26 +02:00
parent 338b219142
commit 0edd82479e
2 changed files with 132 additions and 115 deletions

View File

@ -48,11 +48,16 @@ export default class UWContent {
}
reloadSettings() {
try {
this.logger.log('info', 'debug', 'Things happened in the popup. Will reload extension settings.');
this.init();
} catch (e) {
console.warn('Ultrawidify: settings reload failed. This probably shouldn\'t outright kill the extension, but page reload is recommended.');
}
}
async init(){
try {
if (Debug.debug) {
console.log("[uw::main] loading configuration ...");
}
@ -128,7 +133,11 @@ export default class UWContent {
}
} catch (e) {
console.error('Ultrawidify: failed to start extension. Error:', e)
this.logger.log('error', 'debug', "[uw::init] FAILED TO START EXTENSION. Error:", e);
}
} catch (e) {
console.error('Ultrawidify initalization failed for some reason:', e);
}
}
}

View File

@ -33,8 +33,8 @@ export default class UWServer {
}
async setup() {
try {
// logger is the first thing that goes up
const loggingOptions = {
isBackgroundScript: true,
allowLogging: false,
@ -59,6 +59,9 @@ export default class UWServer {
this.comms.subscribe('emit-logs', () => {}); // we don't need to do anything, this gets forwarded to UI content script as is
browser.tabs.onActivated.addListener((m) => {this.onTabSwitched(m)});
} catch (e) {
console.error(`Ultrawidify [server]: failed to start. Reason:`, e);
}
}
async _promisifyTabsGet(browserObj, tabId){
@ -215,11 +218,13 @@ export default class UWServer {
}
} catch (e) {
console.warn('Ultrawidify [server]: UI setup failed. While problematic, this problem shouldn\'t completely crash the extension.');
this.logger.log('ERROR', 'uwbg', 'UI initialization failed. Reason:', e);
}
}
async initUiAndShowLogger() {
try {
// this implementation is less than optimal and very hacky, but it should work
// just fine for our use case.
this.uiLoggerInitialized = false;
@ -245,7 +250,10 @@ export default class UWServer {
}
await sleep(100);
}
})
});
} catch (e) {
console.warn('Ultrawidify [server]: failed to set up logger UI. While problematic, this problem shouldn\'t completely crash the extension.');
}
}
async getCurrentTab() {