Skip to content

Commit

Permalink
Fix issue knockout#288 (don't throw bare strings)
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveSanderson committed Jan 23, 2012
1 parent 9cd4faa commit a67a13a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/subscribables/dependencyDetection.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ko.dependencyDetection = (function () {

registerDependency: function (subscribable) {
if (!ko.isSubscribable(subscribable))
throw "Only subscribable things can act as dependencies";
throw new Error("Only subscribable things can act as dependencies");
if (_frames.length > 0) {
var topFrame = _frames[_frames.length - 1];
if (ko.utils.arrayIndexOf(topFrame.distinctDependencies, subscribable) >= 0)
Expand Down
4 changes: 2 additions & 2 deletions src/subscribables/dependentObservable.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ko.dependentObservable = function (evaluatorFunctionOrOptions, evaluatorFunction
}
// By here, "options" is always non-null
if (typeof readFunction != "function")
throw "Pass a function that returns the value of the ko.computed";
throw new Error("Pass a function that returns the value of the ko.computed");

var writeFunction = options["write"];
if (!evaluatorFunctionTarget)
Expand Down Expand Up @@ -110,7 +110,7 @@ ko.dependentObservable = function (evaluatorFunctionOrOptions, evaluatorFunction
// Writing a value
writeFunction.apply(evaluatorFunctionTarget, arguments);
} else {
throw "Cannot write a value to a ko.computed unless you specify a 'write' option. If you wish to read the current value, don't pass any parameters.";
throw new Error("Cannot write a value to a ko.computed unless you specify a 'write' option. If you wish to read the current value, don't pass any parameters.");
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/templating/templateEngine.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
ko.templateEngine = function () { };

ko.templateEngine.prototype['renderTemplateSource'] = function (templateSource, bindingContext, options) {
throw "Override renderTemplateSource";
throw new Error("Override renderTemplateSource");
};

ko.templateEngine.prototype['createJavaScriptEvaluatorBlock'] = function (script) {
throw "Override createJavaScriptEvaluatorBlock";
throw new Error("Override createJavaScriptEvaluatorBlock");
};

ko.templateEngine.prototype['makeTemplateSource'] = function(template) {
Expand Down
6 changes: 3 additions & 3 deletions src/templating/templating.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
var _templateEngine;
ko.setTemplateEngine = function (templateEngine) {
if ((templateEngine != undefined) && !(templateEngine instanceof ko.templateEngine))
throw "templateEngine must inherit from ko.templateEngine";
throw new Error("templateEngine must inherit from ko.templateEngine");
_templateEngine = templateEngine;
}

Expand Down Expand Up @@ -50,7 +50,7 @@

// Loosely check result is an array of DOM nodes
if ((typeof renderedNodesArray.length != "number") || (renderedNodesArray.length > 0 && typeof renderedNodesArray[0].nodeType != "number"))
throw "Template engine must return an array of DOM nodes";
throw new Error("Template engine must return an array of DOM nodes");

var haveAddedNodesToParent = false;
switch (renderMode) {
Expand Down Expand Up @@ -79,7 +79,7 @@
ko.renderTemplate = function (template, dataOrBindingContext, options, targetNodeOrNodeArray, renderMode) {
options = options || {};
if ((options['templateEngine'] || _templateEngine) == undefined)
throw "Set a template engine before calling renderTemplate";
throw new Error("Set a template engine before calling renderTemplate");
renderMode = renderMode || "replaceChildren";

if (targetNodeOrNodeArray) {
Expand Down

0 comments on commit a67a13a

Please sign in to comment.