Skip to content

Commit

Permalink
Merge pull request #475 from meteor/feature/improved-errormsg-helpers
Browse files Browse the repository at this point in the history
Feature: addd explicit helper name + viewname to errors, causes…
  • Loading branch information
nachocodoner authored Feb 4, 2025
2 parents 4a953bb + 9adf516 commit e333e09
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/blaze/lookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ Blaze._getTemplateHelper = function (template, name, tmplInstanceFunc) {
if (helper === Blaze._OLDSTYLE_HELPER) {
isKnownOldStyleHelper = true;
} else if (helper != null) {
return wrapHelper(bindDataContext(helper), tmplInstanceFunc);
const printName = `${template.viewName} ${name}`;
return wrapHelper(bindDataContext(helper), tmplInstanceFunc, printName);
} else {
return null;
}
Expand All @@ -100,7 +101,7 @@ Blaze._getTemplateHelper = function (template, name, tmplInstanceFunc) {
return null;
};

const wrapHelper = function (f, templateFunc) {
const wrapHelper = function (f, templateFunc, name = 'template helper') {
if (typeof f !== "function") {
return f;
}
Expand All @@ -109,7 +110,7 @@ const wrapHelper = function (f, templateFunc) {
const self = this;

return Blaze.Template._withTemplateInstanceFunc(templateFunc, function () {
return Blaze._wrapCatchingExceptions(f, 'template helper').apply(self, args);
return Blaze._wrapCatchingExceptions(f, name).apply(self, args);
});
};
};
Expand Down Expand Up @@ -165,7 +166,8 @@ Blaze._getTemplate = function (name, templateInstance) {

Blaze._getGlobalHelper = function (name, templateInstance) {
if (Blaze._globalHelpers[name] != null) {
return wrapHelper(bindDataContext(Blaze._globalHelpers[name]), templateInstance);
const printName = `global helper ${name}`;
return wrapHelper(bindDataContext(Blaze._globalHelpers[name]), templateInstance, printName);
}
return null;
};
Expand Down

0 comments on commit e333e09

Please sign in to comment.