From 7459d35b48adc56432e0b47e301aae8fb50f02a5 Mon Sep 17 00:00:00 2001 From: Geoffrey Longman Date: Thu, 4 Nov 2010 22:47:36 -0400 Subject: [PATCH 1/2] promise.call - apply original arguments --- promise.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/promise.js b/promise.js index cde8183..9ef8a49 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); }); }; From 6e93238ce7f05b357bc13a049e67e987b80f982e Mon Sep 17 00:00:00 2001 From: Thomas Yandell Date: Fri, 11 Jun 2010 17:55:23 +0800 Subject: [PATCH 2/2] detect string exceptions and upgrade to Error objects to make sure error messages are output in node --- promise.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/promise.js b/promise.js index 9ef8a49..ae951a7 100644 --- a/promise.js +++ b/promise.js @@ -196,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; + } } }); }