You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-04 15:02:09 +03:00
* fix #2665 - handle errors in multi/pipeline replies * fix MultiErrorReply replies type * run tests on all versions, remove console.log, fix bug * add errors iterator helper * test `.errors()` as well
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { RedisCommandRawReply } from './commands';
|
||||
|
||||
export class AbortError extends Error {
|
||||
constructor() {
|
||||
super('The command was aborted');
|
||||
@@ -63,3 +65,20 @@ export class ErrorReply extends Error {
|
||||
this.stack = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
export class MultiErrorReply extends ErrorReply {
|
||||
replies;
|
||||
errorIndexes;
|
||||
|
||||
constructor(replies: Array<RedisCommandRawReply | ErrorReply>, errorIndexes: Array<number>) {
|
||||
super(`${errorIndexes.length} commands failed, see .replies and .errorIndexes for more information`);
|
||||
this.replies = replies;
|
||||
this.errorIndexes = errorIndexes;
|
||||
}
|
||||
|
||||
*errors() {
|
||||
for (const index of this.errorIndexes) {
|
||||
yield this.replies[index];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user