diff --git a/src/octoprint/static/js/app/helpers.js b/src/octoprint/static/js/app/helpers.js index dae6d8fd..81c3b9c9 100644 --- a/src/octoprint/static/js/app/helpers.js +++ b/src/octoprint/static/js/app/helpers.js @@ -832,17 +832,21 @@ function callViewModelsIf(allViewModels, method, condition, callback) { _.each(allViewModels, function(viewModel) { if (viewModel.hasOwnProperty(method) && condition(viewModel, method)) { - if (callback == undefined) { - if (parameters != undefined) { - // call the method with the provided parameters - viewModel[method].apply(viewModel, parameters); + try { + if (callback == undefined) { + if (parameters != undefined) { + // call the method with the provided parameters + viewModel[method].apply(viewModel, parameters); + } else { + // call the method without parameters + viewModel[method](); + } } else { - // call the method without parameters - viewModel[method](); + // provide the method to the callback + callback(viewModel[method], viewModel); } - } else { - // provide the method to the callback - callback(viewModel[method], viewModel); + } catch (exc) { + log.error("Error calling", method, "on view model", viewModel.constructor.name, ":", (exc.stack || exc)); } } });