[Pkg-javascript-commits] [node-async] 283/480: Send results to auto callback when an error occurs

Jonas Smedegaard js at moszumanska.debian.org
Fri May 2 08:58:34 UTC 2014


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository node-async.

commit 811f90d52dac6ebf252b6395c9c4bfd65ad9d725
Author: Michael Leaney <leahcimic at gmail.com>
Date:   Wed Feb 13 10:20:21 2013 +1100

    Send results to auto callback when an error occurs
    
    When an error occurs using the auto method, still send the partial
    results to the callback.
---
 lib/async.js       |  2 +-
 test/test-async.js | 19 +++++++++++++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/lib/async.js b/lib/async.js
index 3ebad60..9bcc82e 100755
--- a/lib/async.js
+++ b/lib/async.js
@@ -426,7 +426,7 @@
             var task = (tasks[k] instanceof Function) ? [tasks[k]]: tasks[k];
             var taskCallback = function (err) {
                 if (err) {
-                    callback(err);
+                    callback(err, results);
                     // stop subsequent errors hitting callback multiple times
                     callback = function () {};
                 }
diff --git a/test/test-async.js b/test/test-async.js
index e9efdd3..b447483 100755
--- a/test/test-async.js
+++ b/test/test-async.js
@@ -293,6 +293,25 @@ exports['auto no callback'] = function(test){
     });
 };
 
+exports['auto error should pass partial results'] = function(test) {
+    async.auto({
+        task1: function(callback){
+            callback(false, 'result1');
+        },
+        task2: ['task1', function(callback){
+            callback('testerror');
+        }],
+        task3: ['task2', function(callback){
+            test.ok(false, 'task3 should not be called');
+        }]
+    },
+    function(err, results){
+        test.equals(err, 'testerror');
+        test.equals(results.task1, 'result1');
+    });
+    setTimeout(test.done, 100);
+};
+
 // Issue 24 on github: https://github.com/caolan/async/issues#issue/24
 // Issue 76 on github: https://github.com/caolan/async/issues#issue/76
 exports['auto removeListener has side effect on loop iterator'] = function(test) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-async.git



More information about the Pkg-javascript-commits mailing list