From e57ed922949f4c357e6792df1e1d906cc72b963e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 28 Sep 2015 18:24:56 +0200 Subject: [PATCH] Less repetitious code --- .../static/js/app/viewmodels/settings.js | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/octoprint/static/js/app/viewmodels/settings.js b/src/octoprint/static/js/app/viewmodels/settings.js index 1d78c355..99a65c4e 100644 --- a/src/octoprint/static/js/app/viewmodels/settings.js +++ b/src/octoprint/static/js/app/viewmodels/settings.js @@ -389,14 +389,17 @@ $(function() { self.requestData = function(local) { // handle old parameter format var callback = undefined; - if (_.isFunction(local)) { - log.warn("The callback parameter of SettingsViewModel.requestData is deprecated, the method now returns a promise, please use that instead."); - callback = local; - local = false; - } else if (arguments.length == 2) { - log.warn("The callback parameter of SettingsViewModel.requestData is deprecated, the method now returns a promise, please use that instead."); - callback = arguments[0]; - local = arguments[1]; + if (arguments.length == 2 || _.isFunction(local)) { + var exc = new Error(); + log.warn("The callback parameter of SettingsViewModel.requestData is deprecated, the method now returns a promise, please use that instead. Stacktrace:", (exc.stack || exc.stacktrace || "")); + + if (arguments.length == 2) { + callback = arguments[0]; + local = arguments[1]; + } else { + callback = local; + local = false; + } } // handler for any explicitely provided callbacks @@ -405,7 +408,7 @@ $(function() { try { callback(); } catch (exc) { - log.error("Error calling settings callback", callback, ":", (exc.stack || exc)); + log.error("Error calling settings callback", callback, ":", (exc.stack || exc.stacktrace || exc)); } };