From e2f29799c61394fce5a68031b449daf7c5583fec Mon Sep 17 00:00:00 2001 From: Oliver Smith Date: Thu, 6 Apr 2023 20:09:39 +0000 Subject: [PATCH] =?UTF-8?q?autoconfig:=20wrap=20most=20code=20in=20try?= =?UTF-8?q?=E2=80=A6catch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make debugging easier by printing exceptions to the log. For example: main() failed: TypeError: fragment.contains is not a function --- src/mobile-config-autoconfig.js | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/mobile-config-autoconfig.js b/src/mobile-config-autoconfig.js index 4a58e60..7b6764d 100644 --- a/src/mobile-config-autoconfig.js +++ b/src/mobile-config-autoconfig.js @@ -249,15 +249,26 @@ function css_files_update() { set_firefox_version_previous(ff); } -log("Running mobile-config-autoconfig.js"); +function main() { + log("Running mobile-config-autoconfig.js"); + css_files_update(); -css_files_update(); + // Restart Firefox immediately if one of the files got updated + if (updated == true) + trigger_firefox_restart(); + else + set_default_prefs(); -// Restart Firefox immediately if one of the files got updated -if (updated == true) - trigger_firefox_restart(); -else - set_default_prefs(); + log("Done"); +} -log("Done"); +try { + main(); +} catch(e) { + log("main() failed: " + e); + + // Let Firefox display the generic error message that something went wrong + // in the autoconfig script. + error; +} logFileStream.close();