diff --git a/promise.js b/promise.js index cde8183..ae951a7 100644 --- a/promise.js +++ b/promise.js @@ -94,8 +94,9 @@ Promise.prototype.put = function(propertyName, value){ }; Promise.prototype.call = function(functionName /*, args */){ + var args = Array.prototype.slice.call(arguments, 1); return this.then(function(value){ - return value[functionName].apply(value, Array.prototype.slice.call(arguments, 1)); + return value[functionName].apply(value, args); }); }; @@ -195,7 +196,12 @@ function Deferred(canceller){ if (!dontThrow) { enqueue(function () { if (!handled) { - throw error; + if (typeof(error) === 'string') { + throw new Error(error); + } + else { + throw error; + } } }); }