Better resilience against exceptions in view models in callViewModels
This commit is contained in:
parent
07382d3918
commit
f1a1b851ee
1 changed files with 13 additions and 9 deletions
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue