You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-09 00:22:08 +03:00
handling of errors on multi, now returns 'err' array type
This commit is contained in:
12
index.js
12
index.js
@@ -1011,7 +1011,7 @@ Multi.prototype.HMSET = Multi.prototype.hmset;
|
|||||||
|
|
||||||
Multi.prototype.exec = function (callback) {
|
Multi.prototype.exec = function (callback) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
var errors = [];
|
||||||
// drain queue, callback will catch "QUEUED" or error
|
// drain queue, callback will catch "QUEUED" or error
|
||||||
// TODO - get rid of all of these anonymous functions which are elegant but slow
|
// TODO - get rid of all of these anonymous functions which are elegant but slow
|
||||||
this.queue.forEach(function (args, index) {
|
this.queue.forEach(function (args, index) {
|
||||||
@@ -1037,12 +1037,7 @@ Multi.prototype.exec = function (callback) {
|
|||||||
if (typeof cur[cur.length - 1] === "function") {
|
if (typeof cur[cur.length - 1] === "function") {
|
||||||
cur[cur.length - 1](err);
|
cur[cur.length - 1](err);
|
||||||
} else {
|
} else {
|
||||||
if (callback) {
|
errors.push(new Error(err));
|
||||||
callback(new Error(err));
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
throw new Error(err);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
self.queue.splice(index, 1);
|
self.queue.splice(index, 1);
|
||||||
}
|
}
|
||||||
@@ -1053,7 +1048,8 @@ Multi.prototype.exec = function (callback) {
|
|||||||
return this._client.send_command("EXEC", [], function (err, replies) {
|
return this._client.send_command("EXEC", [], function (err, replies) {
|
||||||
if (err) {
|
if (err) {
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback(new Error(err));
|
errors.push(new Error(err));
|
||||||
|
callback(errors);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
throw new Error(err);
|
throw new Error(err);
|
||||||
|
9
test.js
9
test.js
@@ -320,6 +320,15 @@ tests.MULTI_7 = function () {
|
|||||||
next(name);
|
next(name);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
tests.MULTI_EXCEPTION_1 = function() {
|
||||||
|
client.multi().set("foo").exec(function (err, reply) {
|
||||||
|
/* ... */
|
||||||
|
console.log('CB:', arguments);
|
||||||
|
});
|
||||||
|
// [Error: Error: ERR wrong number of arguments for 'set' command]
|
||||||
|
};
|
||||||
|
|
||||||
tests.FWD_ERRORS_1 = function () {
|
tests.FWD_ERRORS_1 = function () {
|
||||||
var name = "FWD_ERRORS_1";
|
var name = "FWD_ERRORS_1";
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user