From 5118088ad64a7c6554f9fe54d8b3ccd2414336e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 27 Feb 2023 12:06:29 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=8A=20Improve=20JS=20error=20reporting?= =?UTF-8?q?=20in=20Firefox?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It turns out the issues we had with the less helpful JS error output under Firefox was simply due to the error message not being included in the stack trace, vs Chrome where it is. Solved this by always including the message. --- src/octoprint/server/util/webassets.py | 2 +- src/octoprint/static/js/app/helpers.js | 6 +++--- src/octoprint/static/js/app/main.js | 15 ++++++++++----- .../static/js/app/viewmodels/settings.js | 2 +- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/octoprint/server/util/webassets.py b/src/octoprint/server/util/webassets.py index 5fb9d0c80..5d93c2b32 100644 --- a/src/octoprint/server/util/webassets.py +++ b/src/octoprint/server/util/webassets.py @@ -172,7 +172,7 @@ _PLUGIN_BUNDLE_WRAPPER_PREFIX = """// JS assets for plugin {plugin} """ _PLUGIN_BUNDLE_WRAPPER_SUFFIX = """ }} catch (error) {{ - log.error("Error in JS assets for plugin {plugin}:", (error.stack || error)); + log.error("Error in JS assets for plugin {plugin}:", `${{exc.message}}\n${{exc.stack || exc}}`); }} }})(); """ diff --git a/src/octoprint/static/js/app/helpers.js b/src/octoprint/static/js/app/helpers.js index b9fff229a..c2634fd99 100644 --- a/src/octoprint/static/js/app/helpers.js +++ b/src/octoprint/static/js/app/helpers.js @@ -1367,7 +1367,7 @@ function setOnViewModelIf(viewModel, key, value, condition) { "on view model", viewModel.constructor.name, ":", - exc.stack || exc + `${exc.message}\n${exc.stack || exc}` ); } } @@ -1392,7 +1392,7 @@ function callViewModelsIf(allViewModels, method, condition, callback) { "on view model", viewModel.constructor.name, ":", - exc.stack || exc + `${exc.message}\n${exc.stack || exc}` ); } }); @@ -1476,7 +1476,7 @@ function callViewModelIf(viewModel, method, condition, callback, raiseErrors) { "on view model", viewModel.constructor.name, ":", - exc.stack || exc + `${exc.message}\n${exc.stack || exc}` ); } } diff --git a/src/octoprint/static/js/app/main.js b/src/octoprint/static/js/app/main.js index bb5f3ff29..3fae4206a 100644 --- a/src/octoprint/static/js/app/main.js +++ b/src/octoprint/static/js/app/main.js @@ -506,7 +506,12 @@ $(function () { if (typeof Sentry !== "undefined") { Sentry.captureException(exc); } - log.error("Error instantiating", viewModel.name, ":", exc.stack || exc); + log.error( + "Error instantiating", + viewModel.name, + ":", + `${exc.message}\n${exc.stack || exc}` + ); continue; } @@ -794,7 +799,7 @@ $(function () { "Error calling onBeforeBinding on view model", viewModel.constructor.name, ":", - exc.stack || exc + `${exc.message}\n${exc.stack || exc}` ); return; } @@ -829,7 +834,7 @@ $(function () { "of view model", viewModel.constructor.name, ":", - exc.stack || exc + `${exc.message}\n${exc.stack || exc}` ); return; } @@ -887,7 +892,7 @@ $(function () { "to target", target, ":", - exc.stack || exc + `${exc.message}\n${exc.stack || exc}` ); } }); @@ -911,7 +916,7 @@ $(function () { "Error while processing view model", name, "for binding:", - exc.stack || exc + `${exc.message}\n${exc.stack || exc}` ); } }); diff --git a/src/octoprint/static/js/app/viewmodels/settings.js b/src/octoprint/static/js/app/viewmodels/settings.js index 0f97b1da2..085cf1994 100644 --- a/src/octoprint/static/js/app/viewmodels/settings.js +++ b/src/octoprint/static/js/app/viewmodels/settings.js @@ -719,7 +719,7 @@ $(function () { "Error calling settings callback", callback, ":", - exc.stack || exc.stacktrace || exc + `${exc.message}\n${exc.stack || exc}` ); } };